diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-21 10:56:33 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-21 10:56:33 -0700 |
commit | 87112406861c58a342887fb2fe5656b4e40b5397 (patch) | |
tree | 0aca0e18de8359d3843b6dbea625318fa2ed74e1 | |
parent | 4115d04777837dbff7198df6ab75ffd19e6ada3c (diff) | |
download | cryptography-87112406861c58a342887fb2fe5656b4e40b5397.tar.gz cryptography-87112406861c58a342887fb2fe5656b4e40b5397.tar.bz2 cryptography-87112406861c58a342887fb2fe5656b4e40b5397.zip |
whoops, forgotten file
-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) |