Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c01534

Browse files
committed
Add tests for the .copy() methods of both weak dictionary classes.
1 parent 9d2c85d commit 5c01534

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Lib/test/test_weakref.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ def __repr__(self):
149149
"wrong number of weak references to %r!" % o)
150150
verify(o is dict[o.arg],
151151
"wrong object returned by weak dict!")
152+
items1 = dict.items()
153+
items2 = dict.copy().items()
154+
items1.sort()
155+
items2.sort()
156+
verify(items1 == items2,
157+
"cloning of weak-valued dictionary did not work!")
158+
del items1, items2
152159
dict.clear()
153160
print "weak dict test complete"
154161

@@ -165,7 +172,14 @@ def __repr__(self):
165172
"wrong number of weak references to %r!" % o)
166173
verify(o.arg is dict[o],
167174
"wrong object returned by weak dict!")
168-
del objects,o
175+
items1 = dict.items()
176+
items2 = dict.copy().items()
177+
items1.sort()
178+
items2.sort()
179+
verify(items1 == items2,
180+
"cloning of weak-keyed dictionary did not work!")
181+
del items1, items2
182+
del objects, o
169183
verify(len(dict)==0, "deleting the keys did not clear the dictionary")
170184
print "weak key dict test complete"
171185

0 commit comments

Comments
 (0)