summaryrefslogtreecommitdiff
path: root/tests/user_commands/tests.py
diff options
context:
space:
mode:
authorTainara Palmeira <tainarapalmeirag@gmail.com>2024-10-28 14:46:20 +0100
committerClaude Paroz <claude@2xlibre.net>2024-10-29 22:06:28 +0100
commitfc22fdd34f1e55adde161f5f2dca8db90bbfce80 (patch)
tree458408cab2a2cd6a3ac5660f0b5ba905f7cdded2 /tests/user_commands/tests.py
parentd7f78eb5d6c9250789fb3975b01e2a71d0e39577 (diff)
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+..
Diffstat (limited to 'tests/user_commands/tests.py')
-rw-r--r--tests/user_commands/tests.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 8dd07e1c67..2a1e904f3b 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -20,7 +20,6 @@ from django.db import connection
from django.test import SimpleTestCase, override_settings
from django.test.utils import captured_stderr, extend_sys_path
from django.utils import translation
-from django.utils.version import PY314
from .management.commands import dance
@@ -401,11 +400,8 @@ class CommandTests(SimpleTestCase):
self.assertIn("bar", out.getvalue())
def test_subparser_invalid_option(self):
- if PY314:
- msg = "invalid choice: 'test' (choose from foo)"
- else:
- 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):