예제 #1
0
 class AutoCast(Constants):
     __antidote__ = Constants.Conf(auto_cast=True)
     A = const[int]('109')
     B = const[float]('3.14')
     C = const[str](199)
예제 #2
0
 class LimitedAutoCast(Constants):
     __antidote__ = Constants.Conf(auto_cast=[int, float])
     A = const[int]('109')
     B = const[float]('3.14')
     C = const[str](199)
예제 #3
0
def test_conf_repr():
    conf = Constants.Conf()
    assert "auto_cast" in repr(conf)
예제 #4
0
def test_conf_copy(kwargs):
    conf = Constants.Conf().copy(**kwargs)
    for k, v in kwargs.items():
        assert getattr(conf, k) == v
예제 #5
0
def test_conf_error(kwargs, expectation):
    with expectation:
        Constants.Conf(**kwargs)
예제 #6
0
 class Config(Constants):
     __antidote__ = Constants.Conf(auto_cast=[MetaDummy])
     INVALID = const[int]('109')
     INVALID_CAST = const[MetaDummy]('x')
예제 #7
0
 class ImpossibleCast(Constants):
     __antidote__ = Constants.Conf(auto_cast=[MetaDummy])
     A = const[MetaDummy]('x')