[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:19:43 EDT 2022


https://github.com/python/cpython/commit/abc1a8c61c82860e135b1b1fcb01713f8b911cd8
commit: abc1a8c61c82860e135b1b1fcb01713f8b911cd8
branch: 3.11
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:19:37-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 298e374e4cfa..b36804216fa2 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3560,11 +3560,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