Skip to content

Commit 2d7905b

Browse files
author
Yuval Shimon
committed
support pypy
1 parent df74e5c commit 2d7905b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/_pytest/assertion/util.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ def has_default_eq(
146146
for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated"
147147
"""
148148
# inspired from https://github.com/willmcgugan/rich/blob/07d51ffc1aee6f16bd2e5a25b4e82850fb9ed778/rich/pretty.py#L68
149-
if not hasattr(obj.__eq__, "__code__"): # the obj does not have a code attribute
150-
return True
149+
if hasattr(obj.__eq__, "__code__") and hasattr(obj.__eq__.__code__, "co_filename"):
150+
code_filename = obj.__eq__.__code__.co_filename
151151

152-
code_filename = obj.__eq__.__code__.co_filename
152+
if isattrs(obj):
153+
return "attrs generated eq" in code_filename
153154

154-
if isattrs(obj):
155-
return "attrs generated eq" in code_filename
156-
157-
return code_filename == "<string>" # data class
155+
return code_filename == "<string>" # data class
156+
return True
158157

159158

160159
def assertrepr_compare(config, op: str, left: Any, right: Any) -> Optional[List[str]]:

0 commit comments

Comments
 (0)