]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 9 Feb 2022 15:12:32 +0000 (07:12 -0800)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 15:12:32 +0000 (07:12 -0800)
(cherry picked from commit d2d1d49eaccaa83eb8873ba15f2fc9562143bc56)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_typing.py

index 27ec5edd92b7af70f1d7807998ef1453ab00d411..641527329501fa5e4c2a74716358e22b18e350ad 100644 (file)
@@ -2455,6 +2455,10 @@ class ForwardRefTests(BaseTestCase):
         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'))