MCPcopy Index your code
hub / github.com/python/cpython / test_equal_operator_modifying_operand

Method test_equal_operator_modifying_operand

Lib/test/test_dict.py:1265–1290  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1263 support.check_free_after_iterating(self, lambda d: iter(d.items()), dict)
1264
1265 def test_equal_operator_modifying_operand(self):
1266 # test fix for seg fault reported in bpo-27945 part 3.
1267 class X():
1268 def __del__(self):
1269 dict_b.clear()
1270
1271 def __eq__(self, other):
1272 dict_a.clear()
1273 return True
1274
1275 def __hash__(self):
1276 return 13
1277
1278 dict_a = {X(): 0}
1279 dict_b = {X(): X()}
1280 self.assertTrue(dict_a == dict_b)
1281
1282 # test fix for seg fault reported in bpo-38588 part 1.
1283 class Y:
1284 def __eq__(self, other):
1285 dict_d.clear()
1286 return True
1287
1288 dict_c = {0: Y()}
1289 dict_d = {0: set()}
1290 self.assertTrue(dict_c == dict_d)
1291
1292 def test_fromkeys_operator_modifying_dict_operand(self):
1293 # test fix for seg fault reported in issue 27945 part 4a.

Callers

nothing calls this directly

Calls 4

setFunction · 0.85
assertTrueMethod · 0.80
XClass · 0.70
YClass · 0.70

Tested by

no test coverage detected