Skip to content

Commit 263c0dd

Browse files
authored
bpo-46437: remove useless hasattr from test_typing (#30704)
1 parent 4b99803 commit 263c0dd

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Lib/test/test_typing.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3513,11 +3513,10 @@ def test_container(self):
35133513
self.assertNotIsInstance(42, typing.Container)
35143514

35153515
def test_collection(self):
3516-
if hasattr(typing, 'Collection'):
3517-
self.assertIsInstance(tuple(), typing.Collection)
3518-
self.assertIsInstance(frozenset(), typing.Collection)
3519-
self.assertIsSubclass(dict, typing.Collection)
3520-
self.assertNotIsInstance(42, typing.Collection)
3516+
self.assertIsInstance(tuple(), typing.Collection)
3517+
self.assertIsInstance(frozenset(), typing.Collection)
3518+
self.assertIsSubclass(dict, typing.Collection)
3519+
self.assertNotIsInstance(42, typing.Collection)
35213520

35223521
def test_abstractset(self):
35233522
self.assertIsInstance(set(), typing.AbstractSet)
@@ -5130,8 +5129,9 @@ def test_all(self):
51305129
self.assertIn('ValuesView', a)
51315130
self.assertIn('cast', a)
51325131
self.assertIn('overload', a)
5133-
if hasattr(contextlib, 'AbstractContextManager'):
5134-
self.assertIn('ContextManager', a)
5132+
# Context managers.
5133+
self.assertIn('ContextManager', a)
5134+
self.assertIn('AsyncContextManager', a)
51355135
# Check that io and re are not exported.
51365136
self.assertNotIn('io', a)
51375137
self.assertNotIn('re', a)
@@ -5145,8 +5145,6 @@ def test_all(self):
51455145
self.assertIn('SupportsComplex', a)
51465146

51475147
def test_all_exported_names(self):
5148-
import typing
5149-
51505148
actual_all = set(typing.__all__)
51515149
computed_all = {
51525150
k for k, v in vars(typing).items()

0 commit comments

Comments
 (0)