def test_with_params(self, instance: ExceptionWithCode, catalog): instance.__dict__['catalog'] = catalog cloned = instance.with_params(a=1) assert cloned.code == 'code' assert cloned.area == 'area' assert cloned.params == {'a': 1} assert cloned.catalog is catalog assert cloned == instance assert cloned is not instance
def test_clone(self, instance: ExceptionWithCode, catalog): instance.__dict__['catalog'] = catalog cloned = instance.clone() assert cloned.code == 'code' assert cloned.area == 'area' assert cloned.params == {'foo': 'bar'} assert cloned.catalog is None assert cloned == instance assert cloned is not instance
def test_equality(self, instance: ExceptionWithCode, catalog): cloned = instance.clone() instance.__dict__['catalog'] = catalog assert instance == cloned assert instance != {} other_instance = ExceptionWithCode( code='code', area='area', params={'different': 'params'}) assert instance == other_instance assert hash(instance) == hash(other_instance)
def test_with_params(self, instance: ExceptionWithCode, catalog): instance.__dict__["catalog"] = catalog cloned = instance.with_params(a=1) assert cloned.code == "code" assert cloned.area == "area" assert cloned.params == {"a": 1} assert cloned.catalog is catalog assert cloned == instance assert cloned is not instance
def test_equality(self, instance: ExceptionWithCode, catalog): cloned = instance.clone() instance.__dict__['catalog'] = catalog assert instance == cloned assert instance != {} other_instance = ExceptionWithCode(code='code', area='area', params={'different': 'params'}) assert instance == other_instance assert hash(instance) == hash(other_instance)
def test_equality(self, instance: ExceptionWithCode, catalog): cloned = instance.clone() instance.__dict__["catalog"] = catalog assert instance == cloned assert instance != {} other_instance = ExceptionWithCode(code="code", area="area", params={"different": "params"}) assert instance == other_instance assert hash(instance) == hash(other_instance)
def test_clone(self, instance_with_params: ExceptionWithCode, catalog): instance_with_params.__dict__["catalog"] = catalog cloned = instance_with_params.clone() assert cloned.code == "code" assert cloned.area == "area" assert cloned.params == {"foo": "bar"} assert cloned.catalog is None assert cloned == instance_with_params assert cloned is not instance_with_params assert cloned.params is not instance_with_params.params
class ExampleCatalog(ErrorCatalog): default_area = 'EXAMPLE' FOO = ExceptionWithCode() BAR = ExceptionWithCode('CODE', 'AREA')
def instance(self): return ExceptionWithCode(code='code', area='area')
def test_defaults(self): instance = ExceptionWithCode() assert instance.code == '' assert instance.area == '' assert instance.params == {} assert instance.catalog is None
def test_add_instance(self): instance = ExceptionWithCode('BAZ') ExampleCatalog.add_instance(instance) assert instance in ExampleCatalog # noinspection PyUnresolvedReferences assert ExampleCatalog.BAZ is instance
def instance_with_params(self): return ExceptionWithCode(code='code', area='area', params={'foo': 'bar'})
def instance(self): return ExceptionWithCode(code="code", area="area")
def instance_with_params(self): return ExceptionWithCode(code="code", area="area", params={"foo": "bar"})
class ExampleCatalog(ErrorCatalog): default_area = "EXAMPLE" FOO = ExceptionWithCode() BAR = ExceptionWithCode("CODE", "AREA")