summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_genericalias.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-07-01 00:04:50 (GMT)
committerGitHub <noreply@github.com>2023-07-01 00:04:50 (GMT)
commiteb7d6e7ad844955f9af88707d296e003c7ce4394 (patch)
tree952b2865e9612414c207b9deb1cc10e0b14e9956 /Lib/test/test_genericalias.py
parente212618bafaa4f775502e3442de0affb80205b5e (diff)
downloadcpython-eb7d6e7ad844955f9af88707d296e003c7ce4394.zip
cpython-eb7d6e7ad844955f9af88707d296e003c7ce4394.tar.gz
cpython-eb7d6e7ad844955f9af88707d296e003c7ce4394.tar.bz2
gh-105486: Change the `repr` of `ParamSpec` list of args in `GenericAlias` (#105488)
Diffstat (limited to 'Lib/test/test_genericalias.py')
-rw-r--r--Lib/test/test_genericalias.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py
index 24d4216..bf600a0 100644
--- a/Lib/test/test_genericalias.py
+++ b/Lib/test/test_genericalias.py
@@ -209,6 +209,9 @@ class BaseTest(unittest.TestCase):
def test_repr(self):
class MyList(list):
pass
+ class MyGeneric:
+ __class_getitem__ = classmethod(GenericAlias)
+
self.assertEqual(repr(list[str]), 'list[str]')
self.assertEqual(repr(list[()]), 'list[()]')
self.assertEqual(repr(tuple[int, ...]), 'tuple[int, ...]')
@@ -221,6 +224,11 @@ class BaseTest(unittest.TestCase):
self.assertTrue(repr(MyList[int]).endswith('.BaseTest.test_repr.<locals>.MyList[int]'))
self.assertEqual(repr(list[str]()), '[]') # instances should keep their normal repr
+ # gh-105488
+ self.assertTrue(repr(MyGeneric[int]).endswith('MyGeneric[int]'))
+ self.assertTrue(repr(MyGeneric[[]]).endswith('MyGeneric[[]]'))
+ self.assertTrue(repr(MyGeneric[[int, str]]).endswith('MyGeneric[[int, str]]'))
+
def test_exposed_type(self):
import types
a = types.GenericAlias(list, int)