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