mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
bpo-35341: Add generic version of OrderedDict to typing (GH-10850)
This commit is contained in:
parent
32bc11c33c
commit
68b56d02ef
4 changed files with 24 additions and 0 deletions
|
@ -2075,6 +2075,22 @@ class CollectionsAbcTests(BaseTestCase):
|
|||
self.assertIsSubclass(MyDefDict, collections.defaultdict)
|
||||
self.assertNotIsSubclass(collections.defaultdict, MyDefDict)
|
||||
|
||||
def test_ordereddict_instantiation(self):
|
||||
self.assertIs(type(typing.OrderedDict()), collections.OrderedDict)
|
||||
self.assertIs(type(typing.OrderedDict[KT, VT]()), collections.OrderedDict)
|
||||
self.assertIs(type(typing.OrderedDict[str, int]()), collections.OrderedDict)
|
||||
|
||||
def test_ordereddict_subclass(self):
|
||||
|
||||
class MyOrdDict(typing.OrderedDict[str, int]):
|
||||
pass
|
||||
|
||||
od = MyOrdDict()
|
||||
self.assertIsInstance(od, MyOrdDict)
|
||||
|
||||
self.assertIsSubclass(MyOrdDict, collections.OrderedDict)
|
||||
self.assertNotIsSubclass(collections.OrderedDict, MyOrdDict)
|
||||
|
||||
@skipUnless(sys.version_info >= (3, 3), 'ChainMap was added in 3.3')
|
||||
def test_chainmap_instantiation(self):
|
||||
self.assertIs(type(typing.ChainMap()), collections.ChainMap)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue