Fix tests for the 3.10 TypeError message change.

This commit is contained in:
Andrey Rakhmatullin 2021-08-03 20:16:29 +05:00
parent ef6fb933b5
commit 93bf1ae7e3
2 changed files with 9 additions and 7 deletions

View File

@ -878,4 +878,4 @@ class CustomResponseTest(TextResponseTest):
with self.assertRaises(TypeError) as ctx:
r1.replace(unknown="unknown")
self.assertEqual(str(ctx.exception), "__init__() got an unexpected keyword argument 'unknown'")
self.assertTrue(str(ctx.exception).endswith("__init__() got an unexpected keyword argument 'unknown'"))

View File

@ -158,12 +158,14 @@ class CallbackKeywordArgumentsTestCase(TestCase):
if key in line.getMessage():
exceptions[key] = line
self.assertEqual(exceptions['takes_less'].exc_info[0], TypeError)
self.assertEqual(
str(exceptions['takes_less'].exc_info[1]),
"parse_takes_less() got an unexpected keyword argument 'number'"
self.assertTrue(
str(exceptions['takes_less'].exc_info[1]).endswith(
"parse_takes_less() got an unexpected keyword argument 'number'"
)
)
self.assertEqual(exceptions['takes_more'].exc_info[0], TypeError)
self.assertEqual(
str(exceptions['takes_more'].exc_info[1]),
"parse_takes_more() missing 1 required positional argument: 'other'"
self.assertTrue(
str(exceptions['takes_more'].exc_info[1]).endswith(
"parse_takes_more() missing 1 required positional argument: 'other'"
)
)