1
1
import sys
2
2
import pickle
3
3
import typing
4
- import collections .abc
5
4
from unittest import TestCase , main , skipUnless
6
5
from mypy_extensions import TypedDict
7
6
@@ -49,7 +48,9 @@ def test_basics_iterable_syntax(self):
49
48
Emp = TypedDict ('Emp' , {'name' : str , 'id' : int })
50
49
self .assertIsSubclass (Emp , dict )
51
50
self .assertIsSubclass (Emp , typing .MutableMapping )
52
- self .assertNotIsSubclass (Emp , collections .abc .Sequence )
51
+ if sys .version_info [0 ] >= 3 :
52
+ import collections .abc
53
+ self .assertNotIsSubclass (Emp , collections .abc .Sequence )
53
54
jim = Emp (name = 'Jim' , id = 1 )
54
55
self .assertIs (type (jim ), dict )
55
56
self .assertEqual (jim ['name' ], 'Jim' )
@@ -64,7 +65,9 @@ def test_basics_keywords_syntax(self):
64
65
Emp = TypedDict ('Emp' , name = str , id = int )
65
66
self .assertIsSubclass (Emp , dict )
66
67
self .assertIsSubclass (Emp , typing .MutableMapping )
67
- self .assertNotIsSubclass (Emp , collections .abc .Sequence )
68
+ if sys .version_info [0 ] >= 3 :
69
+ import collections .abc
70
+ self .assertNotIsSubclass (Emp , collections .abc .Sequence )
68
71
jim = Emp (name = 'Jim' , id = 1 ) # type: ignore # mypy doesn't support keyword syntax yet
69
72
self .assertIs (type (jim ), dict )
70
73
self .assertEqual (jim ['name' ], 'Jim' )
0 commit comments