diff options
author | Fred Drake <fdrake@acm.org> | 2001-09-06 14:52:39 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-09-06 14:52:39 (GMT) |
commit | ccc7562315184669791c49b728580773f04f01fb (patch) | |
tree | 96dc2cb4e42f9e6a96c4a8db2335b5ab8af68c24 /Lib | |
parent | b663a2ccbdd9bbd9a13f0cea743af709c53ec0c1 (diff) | |
download | cpython-ccc7562315184669791c49b728580773f04f01fb.zip cpython-ccc7562315184669791c49b728580773f04f01fb.tar.gz cpython-ccc7562315184669791c49b728580773f04f01fb.tar.bz2 |
Added tests for key deletion for both Weak*Dictionary flavors.
This covers regression on SF bug #458860.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_weakref.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 341d53f..fa12a6e 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -411,6 +411,28 @@ class MappingTestCase(TestBase): self.check_update(weakref.WeakKeyDictionary, {C(): 1, C(): 2, C(): 3}) + def test_weak_keyed_delitem(self): + d = weakref.WeakKeyDictionary() + o1 = Object('1') + o2 = Object('2') + d[o1] = 'something' + d[o2] = 'something' + self.assert_(len(d) == 2) + del d[o1] + self.assert_(len(d) == 1) + self.assert_(d.keys() == [o2]) + + def test_weak_valued_delitem(self): + d = weakref.WeakValueDictionary() + o1 = Object('1') + o2 = Object('2') + d['something'] = o1 + d['something else'] = o2 + self.assert_(len(d) == 2) + del d['something'] + self.assert_(len(d) == 1) + self.assert_(d.items() == [('something else', o2)]) + run_unittest(ReferencesTestCase) run_unittest(MappingTestCase) |