import pytest from ria_toolkit_oss.utils.abstract_attribute import ABCMeta2, abstract_attribute class InterfaceWithAbstractClassAttributes(metaclass=ABCMeta2): _url = abstract_attribute() _name = abstract_attribute() def __init__(self): pass @property def name(self): return self._name class ClassWithNeitherAbstractAttributeImplemented(InterfaceWithAbstractClassAttributes): def __init__(self): super().__init__() class ClassWithOnlyOneAbstractAttributeImplemented(InterfaceWithAbstractClassAttributes): _url = "https://www.google.com/" def __init__(self): super().__init__() class ClassWithAllAbstractAttributesImplemented(InterfaceWithAbstractClassAttributes): _url = "https://www.google.com/" _name = "Michael Luciuk" def __init__(self): super().__init__() def test_with_neither_attribute_implemented(): with pytest.raises(NotImplementedError): ClassWithNeitherAbstractAttributeImplemented() def test_with_one_attribute_missing(): with pytest.raises(NotImplementedError): ClassWithOnlyOneAbstractAttributeImplemented() def test_with_both_attributes_implemented(): my_class = ClassWithAllAbstractAttributesImplemented() assert my_class.name == "Michael Luciuk"