1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

[4.2.x] Refs #35844 -- Expanded compatibility for expected error messages in command tests on Python 3.12.

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:
Tainara Palmeira 2024-10-28 14:46:20 +01:00 committed by Sarah Boyce
parent 345a6652e6
commit ea4a1fb61e

View File

@ -399,8 +399,8 @@ class CommandTests(SimpleTestCase):
self.assertIn("bar", out.getvalue())
def test_subparser_invalid_option(self):
msg = "invalid choice: 'test' (choose from 'foo')"
with self.assertRaisesMessage(CommandError, msg):
msg = r"invalid choice: 'test' \(choose from '?foo'?\)"
with self.assertRaisesRegex(CommandError, msg):
management.call_command("subparser", "test", 12)
msg = "Error: the following arguments are required: subcommand"
with self.assertRaisesMessage(CommandError, msg):