Skip to content

Commit b4dea46

Browse files
committed
tests: Fix few tests which depend on order of elements in dict.
With dict being unordered of course.
1 parent e2adff3 commit b4dea46

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

tests/basics/dict_clear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
d = {1: 2, 3: 4}
2-
print(d)
2+
print(len(d))
33
d.clear()
44
print(d)
55
d[2] = 42

tests/basics/dict_iterator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
d = {1: 2, 3: 4}
2+
els = []
23
for i in d:
3-
print(i, d[i])
4+
els.append((i, d[i]))
5+
print(sorted(els))

tests/basics/dict_popitem.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
d={1:2,3:4}
2-
print(d.popitem())
3-
print(d)
4-
print(d.popitem())
5-
print(d)
1+
els = []
2+
d = {1:2,3:4}
3+
a = d.popitem()
4+
print(len(d))
5+
els.append(a)
6+
a = d.popitem()
7+
print(len(d))
8+
els.append(a)
69
try:
710
print(d.popitem(), "!!!",)
811
except KeyError:
912
print("Raised KeyError")
1013
else:
1114
print("Did not raise KeyError")
15+
print(sorted(els))
16+

tests/basics/dict_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
d = {1:2, 3:4}
2-
print(d)
2+
print(len(d))
33
d.update(["ab"])
44
print(d[1])
55
print(d[3])

tests/basics/iter-of-iter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
i = iter(iter([1, 2, 3]))
44
print(list(i))
55
i = iter(iter({1:2, 3:4, 5:6}))
6-
print(list(i))
6+
print(sorted(i))
77
i = iter(iter({1, 2, 3}))
88
print(list(i))

0 commit comments

Comments
 (0)