[3.10] gh-102444: Fix minor bugs in test_typing highlighted by pyflakes (#102445) (#102452)

(cherry picked from commit 96e1022)
This commit is contained in:
Alex Waygood 2023-03-05 22:16:08 +00:00 committed by GitHub
parent 9cec6022e4
commit f5280e2ed8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4752,16 +4752,6 @@ class C:
self.assertEqual(get_type_hints(C, globals())['classvar'], ClassVar[int])
self.assertEqual(get_type_hints(C, globals())['const'], Final[int])
def test_hash_eq(self):
self.assertEqual(len({Annotated[int, 4, 5], Annotated[int, 4, 5]}), 1)
self.assertNotEqual(Annotated[int, 4, 5], Annotated[int, 5, 4])
self.assertNotEqual(Annotated[int, 4, 5], Annotated[str, 4, 5])
self.assertNotEqual(Annotated[int, 4], Annotated[int, 4, 4])
self.assertEqual(
{Annotated[int, 4, 5], Annotated[int, 4, 5], Annotated[T, 4, 5]},
{Annotated[int, 4, 5], Annotated[T, 4, 5]}
)
def test_cannot_subclass(self):
with self.assertRaisesRegex(TypeError, "Cannot subclass .*Annotated"):
class C(Annotated):
@ -5309,7 +5299,7 @@ def test_special_attrs2(self):
self.assertEqual(fr.__module__, 'typing')
# Forward refs are currently unpicklable.
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
with self.assertRaises(TypeError) as exc:
with self.assertRaises(TypeError):
pickle.dumps(fr, proto)
self.assertEqual(SpecialAttrsTests.TypeName.__name__, 'TypeName')