aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_interfaces.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_interfaces.py')
-rw-r--r--tests/test_interfaces.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py
index 4d571ea6..97df45a3 100644
--- a/tests/test_interfaces.py
+++ b/tests/test_interfaces.py
@@ -8,7 +8,33 @@ import pytest
import six
-from cryptography.utils import InterfaceNotImplemented, verify_interface
+from cryptography.utils import (
+ InterfaceNotImplemented, register_interface_if, verify_interface
+)
+
+
+def test_register_interface_if_true():
+ @six.add_metaclass(abc.ABCMeta)
+ class SimpleInterface(object):
+ pass
+
+ @register_interface_if(1 == 1, SimpleInterface)
+ class SimpleClass(object):
+ pass
+
+ assert issubclass(SimpleClass, SimpleInterface) is True
+
+
+def test_register_interface_if_false():
+ @six.add_metaclass(abc.ABCMeta)
+ class SimpleInterface(object):
+ pass
+
+ @register_interface_if(1 == 2, SimpleInterface)
+ class SimpleClass(object):
+ pass
+
+ assert issubclass(SimpleClass, SimpleInterface) is False
class TestVerifyInterface(object):
@@ -36,6 +62,8 @@ class TestVerifyInterface(object):
def method(self):
"""Method with no arguments"""
+ # Invoke this to ensure the line is covered
+ NonImplementer().method()
with pytest.raises(InterfaceNotImplemented):
verify_interface(SimpleInterface, NonImplementer)
@@ -51,4 +79,6 @@ class TestVerifyInterface(object):
def property(self):
"""A concrete property"""
+ # Invoke this to ensure the line is covered
+ NonImplementer().property
verify_interface(SimpleInterface, NonImplementer)