]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46437: remove useless `hasattr` from `test_typing` (#30704)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 19 Jan 2022 21:24:27 +0000 (00:24 +0300)
committerGitHub <noreply@github.com>
Wed, 19 Jan 2022 21:24:27 +0000 (13:24 -0800)
Lib/test/test_typing.py

index 8d024514fcb84776702868a664d31f5c5ae32fa7..ce0c940e2a112eecc49b9976e01006d65b75d10b 100644 (file)
@@ -3513,11 +3513,10 @@ class CollectionsAbcTests(BaseTestCase):
         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 @@ class AllTests(BaseTestCase):
         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)
@@ -5145,8 +5145,6 @@ class AllTests(BaseTestCase):
         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()