diff options
author | Ivan Levkivskyi <levkivskyi@gmail.com> | 2018-05-18 23:00:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 23:00:38 (GMT) |
commit | f65e31fee3b55dfb6ed5398179d5c5d6b502dee5 (patch) | |
tree | 10da84e92f284fa9ea467c8e5ed012ac3ccdc1fb /Lib/test/test_typing.py | |
parent | 5634331a76dfe9fbe4b76475e11307a0922d6a15 (diff) | |
download | cpython-f65e31fee3b55dfb6ed5398179d5c5d6b502dee5.zip cpython-f65e31fee3b55dfb6ed5398179d5c5d6b502dee5.tar.gz cpython-f65e31fee3b55dfb6ed5398179d5c5d6b502dee5.tar.bz2 |
bpo-28556: Don't simplify unions at runtime (GH-6841)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r-- | Lib/test/test_typing.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index be768f1..904cd93 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -253,10 +253,11 @@ class UnionTests(BaseTestCase): def test_union_object(self): u = Union[object] self.assertEqual(u, object) - u = Union[int, object] - self.assertEqual(u, object) - u = Union[object, int] - self.assertEqual(u, object) + u1 = Union[int, object] + u2 = Union[object, int] + self.assertEqual(u1, u2) + self.assertNotEqual(u1, object) + self.assertNotEqual(u2, object) def test_unordered(self): u1 = Union[int, float] @@ -267,13 +268,11 @@ class UnionTests(BaseTestCase): t = Union[Employee] self.assertIs(t, Employee) - def test_base_class_disappears(self): - u = Union[Employee, Manager, int] - self.assertEqual(u, Union[int, Employee]) - u = Union[Manager, int, Employee] - self.assertEqual(u, Union[int, Employee]) + def test_base_class_kept(self): u = Union[Employee, Manager] - self.assertIs(u, Employee) + self.assertNotEqual(u, Employee) + self.assertIn(Employee, u.__args__) + self.assertIn(Manager, u.__args__) def test_union_union(self): u = Union[int, float] @@ -317,7 +316,8 @@ class UnionTests(BaseTestCase): def test_union_generalization(self): self.assertFalse(Union[str, typing.Iterable[int]] == str) self.assertFalse(Union[str, typing.Iterable[int]] == typing.Iterable[int]) - self.assertTrue(Union[str, typing.Iterable] == typing.Iterable) + self.assertIn(str, Union[str, typing.Iterable[int]].__args__) + self.assertIn(typing.Iterable[int], Union[str, typing.Iterable[int]].__args__) def test_union_compare_other(self): self.assertNotEqual(Union, object) @@ -917,7 +917,7 @@ class GenericTests(BaseTestCase): self.assertEqual(Union[T, U][int, Union[int, str]], Union[int, str]) class Base: ... class Derived(Base): ... - self.assertEqual(Union[T, Base][Derived], Base) + self.assertEqual(Union[T, Base][Union[Base, Derived]], Union[Base, Derived]) with self.assertRaises(TypeError): Union[T, int][1] |