Skip to content

Commit a069f61

Browse files
author
Joe Jevnik
committed
TST: add test for wrapped function with invalid signature
1 parent f96c378 commit a069f61

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

interface/tests/test_interface.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,33 @@ class C(implements(I)): # pragma: nocover
674674
@wrapping_decorator
675675
def f(self, a, b, c):
676676
pass
677+
678+
679+
def test_wrapped_implementation_incompatible():
680+
class I(Interface): # pragma: nocover
681+
def f(self, a, b, c):
682+
pass
683+
684+
def wrapping_decorator(f):
685+
@wraps(f)
686+
def inner(*args, **kwargs): # pragma: nocover
687+
pass
688+
689+
return inner
690+
691+
with pytest.raises(InvalidImplementation) as e:
692+
class C(implements(I)): # pragma: nocover
693+
@wrapping_decorator
694+
def f(self, a, b): # missing ``c``
695+
pass
696+
697+
actual_message = str(e.value)
698+
expected_message = dedent(
699+
"""
700+
class C failed to implement interface I:
701+
702+
The following methods of I were implemented with invalid signatures:
703+
- f(self, a, b) != f(self, a, b, c)"""
704+
)
705+
706+
assert actual_message == expected_message

0 commit comments

Comments
 (0)