summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/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/admin_scripts/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/admin_scripts/tests.py')
-rw-r--r--tests/admin_scripts/tests.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index fefe4f50bb..6fdd873661 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -34,7 +34,7 @@ from django.db.migrations.recorder import MigrationRecorder
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings
from django.test.utils import captured_stderr, captured_stdout
from django.urls import path
-from django.utils.version import PY313, PY314, get_docs_version
+from django.utils.version import PY313, get_docs_version
from django.views.static import serve
from . import urls
@@ -2355,16 +2355,10 @@ class Discovery(SimpleTestCase):
class CommandDBOptionChoiceTests(SimpleTestCase):
def test_invalid_choice_db_option(self):
- if PY314:
- expected_error = (
- "Error: argument --database: invalid choice: 'deflaut' "
- "(choose from default, other)"
- )
- else:
- expected_error = (
- "Error: argument --database: invalid choice: 'deflaut' "
- "(choose from 'default', 'other')"
- )
+ expected_error = (
+ r"Error: argument --database: invalid choice: 'deflaut' "
+ r"\(choose from '?default'?, '?other'?\)"
+ )
args = [
"changepassword",
"createsuperuser",
@@ -2384,7 +2378,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)