[Python-checkins] bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223)

miss-islington webhook-mailer at python.org
Wed Feb 9 10:12:36 EST 2022


https://github.com/python/cpython/commit/bde3765a3fd21e2ecf595a57998b285e3045f744
commit: bde3765a3fd21e2ecf595a57998b285e3045f744
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-02-09T07:12:32-08:00
summary:

bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223)

(cherry picked from commit d2d1d49eaccaa83eb8873ba15f2fc9562143bc56)

Co-authored-by: Nikita Sobolev <mail at sobolevn.me>

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 27ec5edd92b7a..641527329501f 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'))



More information about the Python-checkins mailing list