Skip to content

Commit 366fc8a

Browse files
committed
more dict tests
1 parent a1847b0 commit 366fc8a

File tree

1 file changed

+26
-0
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests

1 file changed

+26
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_dict.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,3 +828,29 @@ def __hash__(self):
828828
assert d2[MyObject("1")] == 112
829829
del d2[MyObject("1")]
830830
assert "1" not in d2
831+
832+
def test_update_side_effect_on_other():
833+
class X:
834+
def __hash__(self):
835+
return 0
836+
def __eq__(self, o):
837+
other.clear()
838+
return False
839+
840+
other = {'a':1, 'b': 2, X(): 3, 'c':4}
841+
d = {X(): 0, 1: 1}
842+
assert_raises(RuntimeError, d.update, other)
843+
assert 'c' not in d
844+
845+
other = {'a':1, 'b': 2, X(): 3, 'c':4}
846+
d = {X(): 0, 1: 0}
847+
kw = {'kw': 1}
848+
849+
raised = False
850+
try:
851+
d.update(other, **kw)
852+
except RuntimeError:
853+
raised = True
854+
assert raised
855+
856+
assert 'kw' not in d

0 commit comments

Comments
 (0)