summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_clinic.py
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-05-05 12:08:24 (GMT)
committerGitHub <noreply@github.com>2023-05-05 12:08:24 (GMT)
commitd0b4abedfb8b0322df835065f85551d097cfecb8 (patch)
tree95aac253d0e822e6b011fcf95172e2832da39051 /Lib/test/test_clinic.py
parent5245cb64d9a898804edf683427ef4d4fd20ccaec (diff)
downloadcpython-d0b4abedfb8b0322df835065f85551d097cfecb8.zip
cpython-d0b4abedfb8b0322df835065f85551d097cfecb8.tar.gz
cpython-d0b4abedfb8b0322df835065f85551d097cfecb8.tar.bz2
gh-64631: Test exception messages in cloned Argument Clinic funcs (#104167)
Diffstat (limited to 'Lib/test/test_clinic.py')
-rw-r--r--Lib/test/test_clinic.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 4abf739..660f7a1 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -1284,6 +1284,19 @@ class ClinicFunctionalTest(unittest.TestCase):
with self.assertRaisesRegex(TypeError, expected_error):
ac_tester.gh_99240_double_free('a', '\0b')
+ def test_cloned_func_exception_message(self):
+ incorrect_arg = -1 # f1() and f2() accept a single str
+ with self.assertRaisesRegex(TypeError, "clone_f1"):
+ ac_tester.clone_f1(incorrect_arg)
+ with self.assertRaisesRegex(TypeError, "clone_f2"):
+ ac_tester.clone_f2(incorrect_arg)
+
+ def test_cloned_func_with_converter_exception_message(self):
+ for name in "clone_with_conv_f1", "clone_with_conv_f2":
+ with self.subTest(name=name):
+ func = getattr(ac_tester, name)
+ self.assertEqual(func(), name)
+
if __name__ == "__main__":
unittest.main()