summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGiovanni Fabbretti <gfabbretti8>2024-08-23 15:23:51 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-08-23 17:26:28 +0200
commitf72bbd44808452f4a70be5f7b9d35e46dee32e2d (patch)
treefc5106d93e5dfcfce08fb0677e3b98edd5f0f59b /tests
parent47b921391f1df0c5c15e965b43b3a435830ed89b (diff)
Fixed #35689 -- Handled custom labels in LabelCommand.missing_args_message.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_scripts/tests.py15
-rw-r--r--tests/staticfiles_tests/test_management.py5
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 5ee3eeb803..29023b74c3 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -25,6 +25,7 @@ from django.core.management import (
color,
execute_from_command_line,
)
+from django.core.management.base import LabelCommand
from django.core.management.commands.loaddata import Command as LoaddataCommand
from django.core.management.commands.runserver import Command as RunserverCommand
from django.core.management.commands.testserver import Command as TestserverCommand
@@ -2280,6 +2281,20 @@ class CommandTypes(AdminScriptTestCase):
"('settings', None), ('traceback', False), ('verbosity', 1)]",
)
+ def test_custom_label_command_custom_missing_args_message(self):
+ class Command(LabelCommand):
+ missing_args_message = "Missing argument."
+
+ with self.assertRaisesMessage(CommandError, "Error: Missing argument."):
+ call_command(Command())
+
+ def test_custom_label_command_none_missing_args_message(self):
+ class Command(LabelCommand):
+ missing_args_message = None
+
+ with self.assertRaisesMessage(CommandError, ""):
+ call_command(Command())
+
def test_suppress_base_options_command_help(self):
args = ["suppress_base_options_command", "--help"]
out, err = self.run_manage(args)
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index c0d3817383..1b9179af49 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -124,6 +124,11 @@ class TestFindStatic(TestDefaults, CollectionTestCase):
searched_locations,
)
+ def test_missing_args_message(self):
+ msg = "Enter at least one staticfile."
+ with self.assertRaisesMessage(CommandError, msg):
+ call_command("findstatic")
+
class TestConfiguration(StaticFilesTestCase):
def test_location_empty(self):