[Python-checkins] Use more precise exception types in `assertRaises` in typing tests (GH-98650)

miss-islington webhook-mailer at python.org
Tue Oct 25 10:13:05 EDT 2022


https://github.com/python/cpython/commit/750e5048009e36e7c3ca9f396fc82cbcfaf8bd5e
commit: 750e5048009e36e7c3ca9f396fc82cbcfaf8bd5e
branch: 3.10
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-10-25T07:12:59-07:00
summary:

Use more precise exception types in `assertRaises` in typing tests (GH-98650)

(cherry picked from commit 45c89358b71e4638455e75ba6e60b42c511bbc2a)

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 3f38e30881d4..34f944416070 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -2405,11 +2405,11 @@ class D(C):
 
         self.assertEqual(D.__parameters__, ())
 
-        with self.assertRaises(Exception):
+        with self.assertRaises(TypeError):
             D[int]
-        with self.assertRaises(Exception):
+        with self.assertRaises(TypeError):
             D[Any]
-        with self.assertRaises(Exception):
+        with self.assertRaises(TypeError):
             D[T]
 
     def test_new_with_args(self):



More information about the Python-checkins mailing list