summaryrefslogtreecommitdiff
path: root/tests/user_commands
diff options
context:
space:
mode:
authorkihuni <stephenkihuni55@gmail.com>2025-11-02 08:50:45 +0300
committerJacob Walls <jacobtylerwalls@gmail.com>2025-11-20 15:40:07 -0500
commitb1a65eac7c09250d36e12464fc8fff2a401246b6 (patch)
tree50edf2b1eca970b169d75cfdf07d6c8049f1dbff /tests/user_commands
parentee2e0e202874db31449d3c7c292504652fa87f69 (diff)
Fixed #36321 -- Defaulted suggest_on_error=True in management commands.
Python 3.15 defaults suggest_on_error=True, but the feature is available from 3.14, so this change opts in earlier. This change can be reverted when Python 3.15 is the minimum supported version.
Diffstat (limited to 'tests/user_commands')
-rw-r--r--tests/user_commands/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index e282bd4bc9..afd376307a 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -1,5 +1,6 @@
import os
import sys
+import unittest
from argparse import ArgumentDefaultsHelpFormatter
from io import BytesIO, StringIO, TextIOWrapper
from pathlib import Path
@@ -24,6 +25,7 @@ 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, PY315
from .management.commands import dance
from .utils import AssertFormatterFailureCaughtContext
@@ -454,6 +456,20 @@ class CommandTests(SimpleTestCase):
self.assertIn("Working...", out.getvalue())
self.assertIs(mocked_flush.called, True)
+ @unittest.skipUnless(PY314 and not PY315, "Only relevant for Python 3.14")
+ def test_suggest_on_error_defaults_true(self):
+ command = BaseCommand()
+ parser = command.create_parser("prog_name", "subcommand")
+ self.assertTrue(parser.suggest_on_error)
+
+ @unittest.skipUnless(PY314 and not PY315, "Only relevant for Python 3.14")
+ def test_suggest_on_error_explicit_false(self):
+ command = BaseCommand()
+ parser = command.create_parser(
+ "prog_name", "subcommand", suggest_on_error=False
+ )
+ self.assertFalse(parser.suggest_on_error)
+
class CommandRunTests(AdminScriptTestCase):
"""