-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
20 lines (18 loc) · 703 Bytes
/
test.py
File metadata and controls
20 lines (18 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import strict
import unittest
import itertools
class TestTyping(unittest.TestCase):
def test_union(self):
from strict.typing import Union
all_ts = (int, str, dict, set, tuple, list)
for r in range(1, 6):
for ts in itertools.combinations(all_ts, r):
with self.subTest(ts=ts, r=r):
union = Union[ts]
self.assertTrue(all(isinstance(t(), union) for t in ts))
self.assertTrue(all(not isinstance(t(), union)
for t in all_ts
if t not in ts))
if __name__ == '__main__':
## unittest.main()
pass