@@ -3605,6 +3605,30 @@ def test_all(self):
|
3605 | 3605 | self.assertIn('SupportsBytes', a) |
3606 | 3606 | self.assertIn('SupportsComplex', a) |
3607 | 3607 | |
| 3608 | +def test_all_exported_names(self): |
| 3609 | +import typing |
| 3610 | + |
| 3611 | +actual_all = set(typing.__all__) |
| 3612 | +computed_all = { |
| 3613 | +k for k, v in vars(typing).items() |
| 3614 | +# explicitly exported, not a thing with __module__ |
| 3615 | +if k in actual_all or ( |
| 3616 | +# avoid private names |
| 3617 | +not k.startswith('_') and |
| 3618 | +# avoid things in the io / re typing submodules |
| 3619 | +k not in typing.io.__all__ and |
| 3620 | +k not in typing.re.__all__ and |
| 3621 | +k not in {'io', 're'} and |
| 3622 | +# there's a few types and metaclasses that aren't exported |
| 3623 | +not k.endswith(('Meta', '_contra', '_co')) and |
| 3624 | +not k.upper() == k and |
| 3625 | +# but export all things that have __module__ == 'typing' |
| 3626 | +getattr(v, '__module__', None) == typing.__name__ |
| 3627 | + ) |
| 3628 | + } |
| 3629 | +self.assertSetEqual(computed_all, actual_all) |
| 3630 | + |
| 3631 | + |
3608 | 3632 | |
3609 | 3633 | if __name__ == '__main__': |
3610 | 3634 | main() |