mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
Port the dictionary tests from test_types.py to unittest. Collect as much
mapping tests as possible in mapping_test.py and reuse the tests in test_dict.py, test_userdict.py, test_weakref.py, test_os.py and test_shelve.py. From SF patch #736962.
This commit is contained in:
parent
cbd0b365c1
commit
0a6d0ff8d9
7 changed files with 704 additions and 360 deletions
|
@ -912,16 +912,16 @@ class MappingTestCase(TestBase):
|
|||
self.assertEqual(len(d), 0)
|
||||
self.assertEqual(count, 2)
|
||||
|
||||
from test_userdict import TestMappingProtocol
|
||||
from test import mapping_tests
|
||||
|
||||
class WeakValueDictionaryTestCase(TestMappingProtocol):
|
||||
class WeakValueDictionaryTestCase(mapping_tests.BasicTestMappingProtocol):
|
||||
"""Check that WeakValueDictionary 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):
|
||||
class WeakKeyDictionaryTestCase(mapping_tests.BasicTestMappingProtocol):
|
||||
"""Check that WeakKeyDictionary conforms to the mapping protocol"""
|
||||
__ref = {Object("key1"):1, Object("key2"):2, Object("key3"):3}
|
||||
_tested_class = weakref.WeakKeyDictionary
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue