Skip to content

Commit fae5d65

Browse files
committed
Attempt to fix pypy issue
1 parent d79a9dd commit fae5d65

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

testtools/matchers/_exception.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ def __init__(self, exception_matcher=None):
9797
def match(self, matchee):
9898
try:
9999
# Handle staticmethod objects by extracting the underlying function
100-
if isinstance(matchee, staticmethod):
100+
if (
101+
hasattr(matchee, "__func__")
102+
and type(matchee).__name__ == "staticmethod"
103+
):
101104
matchee = matchee.__func__
102105
result = matchee()
103106
return Mismatch(f"{matchee!r} returned {result!r}")

testtools/matchers/_warnings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ def match(self, matchee):
6969
with warnings.catch_warnings(record=True) as w:
7070
warnings.simplefilter("always")
7171
# Handle staticmethod objects by extracting the underlying function
72-
if isinstance(matchee, staticmethod):
72+
if (
73+
hasattr(matchee, "__func__")
74+
and type(matchee).__name__ == "staticmethod"
75+
):
7376
matchee = matchee.__func__
7477
matchee()
7578
if self.warnings_matcher is not None:

testtools/tests/matchers/test_higherorder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class TestAnyMatch(TestCase, TestMatchersInterface):
8181
]
8282

8383

84+
# Module-level function to avoid PyPy compilation issues with staticmethod
8485
def parity(x):
8586
return x % 2
8687

0 commit comments

Comments
 (0)