aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_interfaces.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-21 10:56:33 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-21 10:56:33 -0700
commit87112406861c58a342887fb2fe5656b4e40b5397 (patch)
tree0aca0e18de8359d3843b6dbea625318fa2ed74e1 /tests/test_interfaces.py
parent4115d04777837dbff7198df6ab75ffd19e6ada3c (diff)
downloadcryptography-87112406861c58a342887fb2fe5656b4e40b5397.tar.gz
cryptography-87112406861c58a342887fb2fe5656b4e40b5397.tar.bz2
cryptography-87112406861c58a342887fb2fe5656b4e40b5397.zip
whoops, forgotten file
Diffstat (limited to 'tests/test_interfaces.py')
-rw-r--r--tests/test_interfaces.py40
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)