summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>2021-12-16 14:29:59 (GMT)
committerGitHub <noreply@github.com>2021-12-16 14:29:59 (GMT)
commitd6e13747161d7b634b47d2d3d212ed3be4a21fab (patch)
tree9882b6f1113e19290e8608030310c446546bca11 /Lib/test/test_typing.py
parent4506bbede1644e985991884964b43afa7ee6f609 (diff)
downloadcpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.zip
cpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.tar.gz
cpython-d6e13747161d7b634b47d2d3d212ed3be4a21fab.tar.bz2
bpo-45755: [typing] Reveal class attributes of generic in generic aliases in `dir()` (GH-29962)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 90d6bea..a94d77d 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -5040,6 +5040,17 @@ class SpecialAttrsTests(BaseTestCase):
loaded = pickle.loads(s)
self.assertIs(SpecialAttrsP, loaded)
+ def test_genericalias_dir(self):
+ class Foo(Generic[T]):
+ def bar(self):
+ pass
+ baz = 3
+ # The class attributes of the original class should be visible even
+ # in dir() of the GenericAlias. See bpo-45755.
+ self.assertIn('bar', dir(Foo[int]))
+ self.assertIn('baz', dir(Foo[int]))
+
+
class AllTests(BaseTestCase):
"""Tests for __all__."""