]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 9 Feb 2022 14:23:07 +0000 (17:23 +0300)
committerGitHub <noreply@github.com>
Wed, 9 Feb 2022 14:23:07 +0000 (23:23 +0900)
Lib/test/test_typing.py

index 78e58928332f083550e22b19841bc27de2e00368..6e2a2b1978ab401c8b65011f5ae8655bd97a037e 100644 (file)
@@ -2792,6 +2792,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'))