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:
Tainara Palmeira 2024-10-24 11:27:56 +02:00 committed by Sarah Boyce
parent 7a1fa20e9b
commit 4c3897bb15
3 changed files with 17 additions and 6 deletions

View file

@ -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, get_docs_version
from django.utils.version import PY313, PY314, get_docs_version
from django.views.static import serve
from . import urls
@ -2355,10 +2355,16 @@ class Discovery(SimpleTestCase):
class CommandDBOptionChoiceTests(SimpleTestCase):
def test_invalid_choice_db_option(self):
expected_error = (
"Error: argument --database: invalid choice: "
"'deflaut' (choose from 'default', 'other')"
)
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')"
)
args = [
"changepassword",
"createsuperuser",