From 66d7e32f15baa6ad4ae8719e6d0486e647d56610 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 16 Nov 2023 16:22:58 +0300 Subject: [PATCH 1/4] gh-112155: Run `typing.py` doctests during tests --- Lib/test/test_typing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 1e812e1d525a81..ba3412b6a5429d 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, ignore): + import doctest + tests.addTests(doctest.DocTestSuite(typing)) + return tests + + if __name__ == '__main__': main() From d8e33548afdb04fff64145b717ac2dfa7704f520 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 16 Nov 2023 16:31:40 +0300 Subject: [PATCH 2/4] Fix doctest --- Lib/typing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 14845b36028ca1..bd5589902d21e4 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', 'c'}) + True Raise a TypeError for arguments that are not Protocols. """ From 4fa59acb87871698bdbd22c2b960cb6e83271b7b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 16 Nov 2023 16:50:09 +0300 Subject: [PATCH 3/4] Fix doctest --- Lib/typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/typing.py b/Lib/typing.py index bd5589902d21e4..ac74c913f12c58 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3404,7 +3404,7 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: >>> class P(Protocol): ... def a(self) -> str: ... ... b: int - >>> get_protocol_members(P) == frozenset({'a', 'b', 'c'}) + >>> get_protocol_members(P) == frozenset({'a', 'b'}) True Raise a TypeError for arguments that are not Protocols. From 7b429dba4869f4b9060701f3543396f40e5238d8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 16 Nov 2023 15:25:15 +0000 Subject: [PATCH 4/4] use standard parameter name --- Lib/test/test_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index ba3412b6a5429d..8681e7efba3244 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -9464,7 +9464,7 @@ def test_is_not_instance_of_iterable(self): self.assertNotIsInstance(type_to_test, collections.abc.Iterable) -def load_tests(loader, tests, ignore): +def load_tests(loader, tests, pattern): import doctest tests.addTests(doctest.DocTestSuite(typing)) return tests