Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GH-87390: Add remaining tests for PEP 646 #98267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 25, 2022
61 changes: 10 additions & 51 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,11 @@ class MyList(list):
self.assertEqual(repr(list[str]), 'list[str]')
self.assertEqual(repr(list[()]), 'list[()]')
self.assertEqual(repr(tuple[int, ...]), 'tuple[int, ...]')
x1 = tuple[
tuple( # Effectively the same as starring; TODO
tuple[int]
)
]
x1 = tuple[*tuple[int]]
self.assertEqual(repr(x1), 'tuple[*tuple[int]]')
x2 = tuple[
tuple( # Ditto TODO
tuple[int, str]
)
]
x2 = tuple[*tuple[int, str]]
self.assertEqual(repr(x2), 'tuple[*tuple[int, str]]')
x3 = tuple[
tuple( # Ditto TODO
tuple[int, ...]
)
]
x3 = tuple[*tuple[int, ...]]
self.assertEqual(repr(x3), 'tuple[*tuple[int, ...]]')
self.assertTrue(repr(MyList[int]).endswith('.BaseTest.test_repr.<locals>.MyList[int]'))
self.assertEqual(repr(list[str]()), '[]') # instances should keep their normal repr
Expand Down Expand Up @@ -275,42 +263,24 @@ def test_parameters(self):
self.assertEqual(L5.__args__, (Callable[[K, V], K],))
self.assertEqual(L5.__parameters__, (K, V))

T1 = tuple[
tuple( # Ditto TODO
tuple[int]
)
]
T1 = tuple[*tuple[int]]
self.assertEqual(
T1.__args__,
tuple( # Ditto TODO
tuple[int]
)
(*tuple[int],),
)
self.assertEqual(T1.__parameters__, ())

T2 = tuple[
tuple( # Ditto TODO
tuple[T]
)
]
T2 = tuple[*tuple[T]]
self.assertEqual(
T2.__args__,
tuple( # Ditto TODO
tuple[T]
)
(*tuple[T],),
)
self.assertEqual(T2.__parameters__, (T,))

T4 = tuple[
tuple( # Ditto TODO
tuple[int, str]
)
]
T4 = tuple[*tuple[int, str]]
self.assertEqual(
T4.__args__,
tuple( # Ditto TODO
tuple[int, str]
)
(*tuple[int, str],),
)
self.assertEqual(T4.__parameters__, ())

Expand Down Expand Up @@ -345,18 +315,7 @@ def test_equality(self):
self.assertEqual(list[int], list[int])
self.assertEqual(dict[str, int], dict[str, int])
self.assertEqual((*tuple[int],)[0], (*tuple[int],)[0])
self.assertEqual(
tuple[
tuple( # Effectively the same as starring; TODO
tuple[int]
)
],
tuple[
tuple( # Ditto TODO
tuple[int]
)
]
)
self.assertEqual(tuple[*tuple[int]], tuple[*tuple[int]])
self.assertNotEqual(dict[str, int], dict[str, str])
self.assertNotEqual(list, list[int])
self.assertNotEqual(list[int], list)
Expand Down
Loading