Skip to content

Commit 3b51926

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 981c1dc commit 3b51926

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

32323232
def test_collection(self):
3233-
if hasattr(typing, 'Collection'):
3234-
self.assertIsInstance(tuple(), typing.Collection)
3235-
self.assertIsInstance(frozenset(), typing.Collection)
3236-
self.assertIsSubclass(dict, typing.Collection)
3237-
self.assertNotIsInstance(42, typing.Collection)
3233+
self.assertIsInstance(tuple(), typing.Collection)
3234+
self.assertIsInstance(frozenset(), typing.Collection)
3235+
self.assertIsSubclass(dict, typing.Collection)
3236+
self.assertNotIsInstance(42, typing.Collection)
32383237

32393238
def test_abstractset(self):
32403239
self.assertIsInstance(set(), typing.AbstractSet)
@@ -4321,8 +4320,9 @@ def test_all(self):
43214320
self.assertIn('ValuesView', a)
43224321
self.assertIn('cast', a)
43234322
self.assertIn('overload', a)
4324-
if hasattr(contextlib, 'AbstractContextManager'):
4325-
self.assertIn('ContextManager', a)
4323+
# Context managers.
4324+
self.assertIn('ContextManager', a)
4325+
self.assertIn('AsyncContextManager', a)
43264326
# Check that io and re are not exported.
43274327
self.assertNotIn('io', a)
43284328
self.assertNotIn('re', a)
@@ -4336,8 +4336,6 @@ def test_all(self):
43364336
self.assertIn('SupportsComplex', a)
43374337

43384338
def test_all_exported_names(self):
4339-
import typing
4340-
43414339
actual_all = set(typing.__all__)
43424340
computed_all = {
43434341
k for k, v in vars(typing).items()

0 commit comments

Comments
 (0)