diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-12-17 03:33:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 03:33:07 -0800 |
commit | 87539cc716fab47cd4f501f2441c4ab8e80bce6f (patch) | |
tree | 027ad2c5418f704749cd8e013685239bc5ae6ec0 /Lib/test | |
parent | 9fe8fb74a1e21ab881c70111813266d67bfda016 (diff) | |
download | cpython-git-87539cc716fab47cd4f501f2441c4ab8e80bce6f.tar.gz |
bpo-45755: [typing] Reveal class attributes of generic in generic aliases in `dir()` (GH-29962)
(cherry picked from commit d6e13747161d7b634b47d2d3d212ed3be4a21fab)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_typing.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index fdec29ea58..82b6f8c1c6 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4994,6 +4994,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__.""" |