diff options
author | Raymond Hettinger <python@rcn.com> | 2003-03-09 07:05:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-03-09 07:05:43 (GMT) |
commit | 2c2d322884ee72077a256ec3cd0aa9ce3580eedc (patch) | |
tree | d64fac31dcecd48ed44aceb9d5fb6d8dc415e95f /Lib/test/test_weakref.py | |
parent | 42182ebaf6387371c238d2a3484e7f1e085c9d1c (diff) | |
download | cpython-2c2d322884ee72077a256ec3cd0aa9ce3580eedc.zip cpython-2c2d322884ee72077a256ec3cd0aa9ce3580eedc.tar.gz cpython-2c2d322884ee72077a256ec3cd0aa9ce3580eedc.tar.bz2 |
SF patch #667730: More DictMixin
* Adds missing pop() methods to weakref.py
* Expands test suite to broaden coverage of objects with
a mapping interface.
Contributed by Sebastien Keim.
Diffstat (limited to 'Lib/test/test_weakref.py')
-rw-r--r-- | Lib/test/test_weakref.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py index 3a548cd..b078b17 100644 --- a/Lib/test/test_weakref.py +++ b/Lib/test/test_weakref.py @@ -517,11 +517,28 @@ class MappingTestCase(TestBase): self.assert_(len(d) == 1) self.assert_(d.items() == [('something else', o2)]) +from test_userdict import TestMappingProtocol + +class WeakValueDictionaryTestCase(TestMappingProtocol): + """Check that WeakValueDictionary class conforms to the mapping protocol""" + __ref = {"key1":Object(1), "key2":Object(2), "key3":Object(3)} + _tested_class = weakref.WeakValueDictionary + def _reference(self): + return self.__ref.copy() + +class WeakKeyDictionaryTestCase(TestMappingProtocol): + """Check that WeakKeyDictionary class conforms to the mapping protocol""" + __ref = {Object("key1"):1, Object("key2"):2, Object("key3"):3} + _tested_class = weakref.WeakKeyDictionary + def _reference(self): + return self.__ref.copy() def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ReferencesTestCase)) suite.addTest(unittest.makeSuite(MappingTestCase)) + suite.addTest(unittest.makeSuite(WeakValueDictionaryTestCase)) + suite.addTest(unittest.makeSuite(WeakKeyDictionaryTestCase)) test_support.run_suite(suite) |