summaryrefslogtreecommitdiffstats
path: root/support/testing/tests/package/sample_python_constantly.py
blob: 570cf85b236c58f2cf5c4eeb4e11ed7df846134a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from constantly import ValueConstant, Values


class RESULT(Values):
    OK = ValueConstant(0)
    FAIL = ValueConstant(-1)

    @classmethod
    def get(cls, rc):
        if rc == 0:
            return cls.OK
        else:
            return cls.FAIL


print(list(RESULT.iterconstants()))
assert(RESULT.OK < RESULT.FAIL)
assert(RESULT.OK.value > RESULT.FAIL.value)
assert(RESULT.get(-5) == RESULT.FAIL)
OpenPOWER on IntegriCloud