From 87112406861c58a342887fb2fe5656b4e40b5397 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 21 Oct 2014 10:56:33 -0700 Subject: whoops, forgotten file --- tests/test_interfaces.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_interfaces.py (limited to 'tests') 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) -- cgit v1.2.3