summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakref.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-01 03:06:53 (GMT)
committerFred Drake <fdrake@acm.org>2001-03-01 03:06:53 (GMT)
commit5c015344a69d2c3e047831d2169f4fd842e27531 (patch)
treea194dad47c625455127587735a5663e26cdba016 /Lib/test/test_weakref.py
parent9d2c85dec7262475b83d45fdb53651c9c069e1cb (diff)
downloadcpython-5c015344a69d2c3e047831d2169f4fd842e27531.zip
cpython-5c015344a69d2c3e047831d2169f4fd842e27531.tar.gz
cpython-5c015344a69d2c3e047831d2169f4fd842e27531.tar.bz2
Add tests for the .copy() methods of both weak dictionary classes.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r--Lib/test/test_weakref.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index befa70d..a468575 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -149,6 +149,13 @@ for o in objects:
"wrong number of weak references to %r!" % o)
verify(o is dict[o.arg],
"wrong object returned by weak dict!")
+items1 = dict.items()
+items2 = dict.copy().items()
+items1.sort()
+items2.sort()
+verify(items1 == items2,
+ "cloning of weak-valued dictionary did not work!")
+del items1, items2
dict.clear()
print "weak dict test complete"
@@ -165,7 +172,14 @@ for o in objects:
"wrong number of weak references to %r!" % o)
verify(o.arg is dict[o],
"wrong object returned by weak dict!")
-del objects,o
+items1 = dict.items()
+items2 = dict.copy().items()
+items1.sort()
+items2.sort()
+verify(items1 == items2,
+ "cloning of weak-keyed dictionary did not work!")
+del items1, items2
+del objects, o
verify(len(dict)==0, "deleting the keys did not clear the dictionary")
print "weak key dict test complete"