mirror of
https://github.com/django/django.git
synced 2025-01-18 06:12:23 +00:00
Refs #35844 -- Corrected expected error messages in commands tests on Python 3.14+.
Updated CommandTests.test_subparser_invalid_option and CommandDBOptionChoiceTests.test_invalid_choice_db_option to address changes in Python 3.14+ error handling.
This commit is contained in:
parent
7a1fa20e9b
commit
4c3897bb15
@ -19,6 +19,7 @@ PY310 = sys.version_info >= (3, 10)
|
|||||||
PY311 = sys.version_info >= (3, 11)
|
PY311 = sys.version_info >= (3, 11)
|
||||||
PY312 = sys.version_info >= (3, 12)
|
PY312 = sys.version_info >= (3, 12)
|
||||||
PY313 = sys.version_info >= (3, 13)
|
PY313 = sys.version_info >= (3, 13)
|
||||||
|
PY314 = sys.version_info >= (3, 14)
|
||||||
|
|
||||||
|
|
||||||
def get_version(version=None):
|
def get_version(version=None):
|
||||||
|
@ -34,7 +34,7 @@ from django.db.migrations.recorder import MigrationRecorder
|
|||||||
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings
|
from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings
|
||||||
from django.test.utils import captured_stderr, captured_stdout
|
from django.test.utils import captured_stderr, captured_stdout
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from django.utils.version import PY313, get_docs_version
|
from django.utils.version import PY313, PY314, get_docs_version
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
|
|
||||||
from . import urls
|
from . import urls
|
||||||
@ -2355,10 +2355,16 @@ class Discovery(SimpleTestCase):
|
|||||||
|
|
||||||
class CommandDBOptionChoiceTests(SimpleTestCase):
|
class CommandDBOptionChoiceTests(SimpleTestCase):
|
||||||
def test_invalid_choice_db_option(self):
|
def test_invalid_choice_db_option(self):
|
||||||
expected_error = (
|
if PY314:
|
||||||
"Error: argument --database: invalid choice: "
|
expected_error = (
|
||||||
"'deflaut' (choose from 'default', 'other')"
|
"Error: argument --database: invalid choice: 'deflaut' "
|
||||||
)
|
"(choose from default, other)"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
expected_error = (
|
||||||
|
"Error: argument --database: invalid choice: 'deflaut' "
|
||||||
|
"(choose from 'default', 'other')"
|
||||||
|
)
|
||||||
args = [
|
args = [
|
||||||
"changepassword",
|
"changepassword",
|
||||||
"createsuperuser",
|
"createsuperuser",
|
||||||
|
@ -20,6 +20,7 @@ from django.db import connection
|
|||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
from django.test.utils import captured_stderr, extend_sys_path
|
from django.test.utils import captured_stderr, extend_sys_path
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
from django.utils.version import PY314
|
||||||
|
|
||||||
from .management.commands import dance
|
from .management.commands import dance
|
||||||
|
|
||||||
@ -400,7 +401,10 @@ class CommandTests(SimpleTestCase):
|
|||||||
self.assertIn("bar", out.getvalue())
|
self.assertIn("bar", out.getvalue())
|
||||||
|
|
||||||
def test_subparser_invalid_option(self):
|
def test_subparser_invalid_option(self):
|
||||||
msg = "invalid choice: 'test' (choose from 'foo')"
|
if PY314:
|
||||||
|
msg = "invalid choice: 'test' (choose from foo)"
|
||||||
|
else:
|
||||||
|
msg = "invalid choice: 'test' (choose from 'foo')"
|
||||||
with self.assertRaisesMessage(CommandError, msg):
|
with self.assertRaisesMessage(CommandError, msg):
|
||||||
management.call_command("subparser", "test", 12)
|
management.call_command("subparser", "test", 12)
|
||||||
msg = "Error: the following arguments are required: subcommand"
|
msg = "Error: the following arguments are required: subcommand"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user