Skip to content

Commit 8d20022

Browse files
committed
fixing pypy3 fork of hashing test
1 parent 95c9f83 commit 8d20022

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

tests/test_hash.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,11 @@ class MyEnum(Enum):
207207
A = 1
208208
B = 2
209209

210-
# checking if pypy3 is running the test
211-
# in that case due to a difference of string interning implementation
212-
# the ids of strings change
213-
if pypy3:
214-
# only compare the hashes for the enum instances themselves
215-
assert DeepHashPrep(MyEnum.A)[MyEnum.A] == r'objMyEnum:{str:__objclass__:EnumMeta:objMyEnum:{str:_name_:str:B;str:_value_:int:2};str:_name_:str:A;str:_value_:int:1}'
216-
assert DeepHashPrep(MyEnum.B)[MyEnum.B] == r'objMyEnum:{str:__objclass__:EnumMeta:objMyEnum:{str:_name_:str:A;str:_value_:int:1};str:_name_:str:B;str:_value_:int:2}'
217-
assert DeepHashPrep(MyEnum(1))[MyEnum.A] == r'objMyEnum:{str:__objclass__:EnumMeta:objMyEnum:{str:_name_:str:B;str:_value_:int:2};str:_name_:str:A;str:_value_:int:1}'
218-
else:
219-
assert DeepHashPrep(MyEnum.A) == DeepHashPrep(MyEnum.A)
220-
assert DeepHashPrep(MyEnum.A) == DeepHashPrep(MyEnum(1))
221-
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.A.name)
222-
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.A.value)
223-
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.B)
210+
assert DeepHashPrep(MyEnum.A)[MyEnum.A] == r'objMyEnum:{str:_name_:str:A;str:_value_:int:1}'
211+
assert DeepHashPrep(MyEnum.A) == DeepHashPrep(MyEnum(1))
212+
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.A.name)
213+
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.A.value)
214+
assert DeepHashPrep(MyEnum.A) != DeepHashPrep(MyEnum.B)
224215

225216
def test_dict_hash(self):
226217
string1 = "a"

0 commit comments

Comments
 (0)