From 43b0d8e6bf7ba0c480ec950f7e8f7270c69caef3 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 19 Jan 2022 20:43:01 +0300 Subject: [PATCH 1/2] bpo-46437: remove useless `hasattr` from `test_typing` --- Lib/test/test_typing.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 8d024514fcb847..0ac62f4034fcfb 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3513,11 +3513,10 @@ def test_container(self): self.assertNotIsInstance(42, typing.Container) def test_collection(self): - if hasattr(typing, 'Collection'): - self.assertIsInstance(tuple(), typing.Collection) - self.assertIsInstance(frozenset(), typing.Collection) - self.assertIsSubclass(dict, typing.Collection) - self.assertNotIsInstance(42, typing.Collection) + self.assertIsInstance(tuple(), typing.Collection) + self.assertIsInstance(frozenset(), typing.Collection) + self.assertIsSubclass(dict, typing.Collection) + self.assertNotIsInstance(42, typing.Collection) def test_abstractset(self): self.assertIsInstance(set(), typing.AbstractSet) @@ -5130,8 +5129,9 @@ def test_all(self): self.assertIn('ValuesView', a) self.assertIn('cast', a) self.assertIn('overload', a) - if hasattr(contextlib, 'AbstractContextManager'): - self.assertIn('ContextManager', a) + # Context managers. + self.assertIn('ContextManager', a) + self.assertIn('AsyncContextManager', a) # Check that io and re are not exported. self.assertNotIn('io', a) self.assertNotIn('re', a) From c3d0c2e27947a3b5faea81e663cbe77ac32ac2b9 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 19 Jan 2022 20:46:52 +0300 Subject: [PATCH 2/2] Update test_typing.py --- Lib/test/test_typing.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 0ac62f4034fcfb..ce0c940e2a112e 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -5145,8 +5145,6 @@ def test_all(self): self.assertIn('SupportsComplex', a) def test_all_exported_names(self): - import typing - actual_all = set(typing.__all__) computed_all = { k for k, v in vars(typing).items()