From 5ace575398e113bdfa2bf7d7110b4aed8d1a0336 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 9 Feb 2022 17:23:07 +0300 Subject: [PATCH] bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223) (cherry picked from commit d2d1d49eaccaa83eb8873ba15f2fc9562143bc56) Co-authored-by: Nikita Sobolev --- Lib/test/test_typing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 27ec5edd92b7af..641527329501fa 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -2455,6 +2455,10 @@ def test_forwardref_subclass_type_error(self): with self.assertRaises(TypeError): issubclass(int, fr) + def test_forwardref_only_str_arg(self): + with self.assertRaises(TypeError): + typing.ForwardRef(1) # only `str` type is allowed + def test_forward_equality(self): fr = typing.ForwardRef('int') self.assertEqual(fr, typing.ForwardRef('int'))