mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[5.1.x] Refs #35844 -- Expanded compatibility for expected error messages in command tests on Python 3.12 and 3.13.
Updated CommandTests.test_subparser_invalid_option and CommandDBOptionChoiceTests.test_invalid_choice_db_option to use assertRaisesRegex() for compatibility with modified error messages in Python 3.12, 3.13, and 3.14+..
Backport of fc22fdd34f from main.
This commit is contained in:
committed by
Sarah Boyce
parent
c5ddc8550c
commit
b57a8395b5
@@ -2304,8 +2304,8 @@ class Discovery(SimpleTestCase):
|
||||
class CommandDBOptionChoiceTests(SimpleTestCase):
|
||||
def test_invalid_choice_db_option(self):
|
||||
expected_error = (
|
||||
"Error: argument --database: invalid choice: "
|
||||
"'deflaut' (choose from 'default', 'other')"
|
||||
r"Error: argument --database: invalid choice: 'deflaut' "
|
||||
r"\(choose from '?default'?, '?other'?\)"
|
||||
)
|
||||
args = [
|
||||
"changepassword",
|
||||
@@ -2326,7 +2326,7 @@ class CommandDBOptionChoiceTests(SimpleTestCase):
|
||||
]
|
||||
|
||||
for arg in args:
|
||||
with self.assertRaisesMessage(CommandError, expected_error):
|
||||
with self.assertRaisesRegex(CommandError, expected_error):
|
||||
call_command(arg, "--database", "deflaut", verbosity=0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user