diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_interfaces.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py new file mode 100644 index 00000000..e8e97022 --- /dev/null +++ b/tests/test_interfaces.py @@ -0,0 +1,40 @@ +import abc + +import pytest + +import six + +from cryptography.utils import ( + InterfaceNotImplemented, register_interface, verify_interface +) + + +class TestVerifyInterface(object): + def test_verify_missing_method(self): + @six.add_metaclass(abc.ABCMeta) + class SimpleInterface(object): + @abc.abstractmethod + def method(self): + pass + + @register_interface(SimpleInterface) + class NonImplementer(object): + pass + + with pytest.raises(InterfaceNotImplemented): + verify_interface(SimpleInterface, NonImplementer) + + def test_different_arguments(self): + @six.add_metaclass(abc.ABCMeta) + class SimpleInterface(object): + @abc.abstractmethod + def method(self, a): + pass + + @register_interface(SimpleInterface) + class NonImplementer(object): + def method(self): + pass + + with pytest.raises(InterfaceNotImplemented): + verify_interface(SimpleInterface, NonImplementer) |