Skip to content

Commit 07b12fd

Browse files
bpo-46437: remove useless hasattr from test_typing (GH-30704)
(cherry picked from commit 263c0dd) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent ee07750 commit 07b12fd

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
@@ -3439,11 +3439,10 @@ def test_container(self):
34393439
self.assertNotIsInstance(42, typing.Container)
34403440

34413441
def test_collection(self):
3442-
if hasattr(typing, 'Collection'):
3443-
self.assertIsInstance(tuple(), typing.Collection)
3444-
self.assertIsInstance(frozenset(), typing.Collection)
3445-
self.assertIsSubclass(dict, typing.Collection)
3446-
self.assertNotIsInstance(42, typing.Collection)
3442+
self.assertIsInstance(tuple(), typing.Collection)
3443+
self.assertIsInstance(frozenset(), typing.Collection)
3444+
self.assertIsSubclass(dict, typing.Collection)
3445+
self.assertNotIsInstance(42, typing.Collection)
34473446

34483447
def test_abstractset(self):
34493448
self.assertIsInstance(set(), typing.AbstractSet)
@@ -5033,8 +5032,9 @@ def test_all(self):
50335032
self.assertIn('ValuesView', a)
50345033
self.assertIn('cast', a)
50355034
self.assertIn('overload', a)
5036-
if hasattr(contextlib, 'AbstractContextManager'):
5037-
self.assertIn('ContextManager', a)
5035+
# Context managers.
5036+
self.assertIn('ContextManager', a)
5037+
self.assertIn('AsyncContextManager', a)
50385038
# Check that io and re are not exported.
50395039
self.assertNotIn('io', a)
50405040
self.assertNotIn('re', a)
@@ -5048,8 +5048,6 @@ def test_all(self):
50485048
self.assertIn('SupportsComplex', a)
50495049

50505050
def test_all_exported_names(self):
5051-
import typing
5052-
50535051
actual_all = set(typing.__all__)
50545052
computed_all = {
50555053
k for k, v in vars(typing).items()

0 commit comments

Comments
 (0)