From 7680da458398c5a08b9c32785b1eeb7b7c0887e4 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 16 Nov 2023 18:40:09 +0300 Subject: [PATCH] gh-112155: Run `typing.py` doctests as part of `test_typing` (#112156) --- Lib/test/test_typing.py | 6 ++++++ Lib/typing.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 1e812e1d525a81..8681e7efba3244 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -9464,5 +9464,11 @@ def test_is_not_instance_of_iterable(self): self.assertNotIsInstance(type_to_test, collections.abc.Iterable) +def load_tests(loader, tests, pattern): + import doctest + tests.addTests(doctest.DocTestSuite(typing)) + return tests + + if __name__ == '__main__': main() diff --git a/Lib/typing.py b/Lib/typing.py index 3493257677c7ff..5e3e1f298295c7 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3404,8 +3404,8 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: >>> class P(Protocol): ... def a(self) -> str: ... ... b: int - >>> get_protocol_members(P) - frozenset({'a', 'b'}) + >>> get_protocol_members(P) == frozenset({'a', 'b'}) + True Raise a TypeError for arguments that are not Protocols. """