summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTainara Palmeira <tainarapalmeirag@gmail.com>2024-10-28 14:46:20 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-10-30 11:32:52 +0100
commitea4a1fb61e0bc6a4294a0123b82183da947e5efb (patch)
treeda733d8a233d7a8cabc66dbf1ae383cadea7adf5 /tests
parent345a6652e6a15febbf4f68351dcea5dd674ea324 (diff)
[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 fc22fdd34f1e55adde161f5f2dca8db90bbfce80 from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/user_commands/tests.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 408108b552..1379d75b42 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -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):