summaryrefslogtreecommitdiff
path: root/tests/admin_scripts
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2025-07-22 20:41:41 -0700
committernessita <124304+nessita@users.noreply.github.com>2025-07-23 20:17:55 -0300
commit69a93a88edb56ba47f624dac7a21aacc47ea474f (patch)
treef57507a4435d032493cae40e06ecb254790b67b2 /tests/admin_scripts
parent55b0cc21310b76ce4018dd793ba50556eaf0af06 (diff)
Refs #36500 -- Rewrapped long docstrings and block comments via a script.
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
Diffstat (limited to 'tests/admin_scripts')
-rw-r--r--tests/admin_scripts/tests.py79
1 files changed, 60 insertions, 19 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index a272fced74..97d2d7cf7e 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -191,7 +191,10 @@ class AdminScriptTestCase(SimpleTestCase):
)
def assertNotInOutput(self, stream, msg):
- "Utility assertion: assert that the given message doesn't exist in the output"
+ """
+ Utility assertion: assert that the given message doesn't exist in the
+ output
+ """
self.assertNotIn(
msg, stream, "'%s' matches actual output text '%s'" % (msg, stream)
)
@@ -503,7 +506,10 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
self.assertOutput(err, "No module named '?bad_settings'?", regex=True)
def test_custom_command(self):
- "minimal: django-admin can't execute user commands unless settings are provided"
+ """
+ minimal: django-admin can't execute user commands unless settings are
+ provided
+ """
args = ["noargs_command"]
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
@@ -745,7 +751,10 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
)
def test_setup_environ_custom_template(self):
- "directory: startapp creates the correct directory with a custom template"
+ """
+ directory: startapp creates the correct directory with a custom
+ template
+ """
template_path = os.path.join(custom_templates_dir, "app_template")
args = ["startapp", "--template", template_path, "custom_settings_test"]
app_path = os.path.join(self.test_dir, "custom_settings_test")
@@ -1089,7 +1098,10 @@ class ManageMinimalSettings(AdminScriptTestCase):
self.assertOutput(err, "No installed app with label 'admin_scripts'.")
def test_builtin_with_settings(self):
- "minimal: manage.py builtin commands fail if settings are provided as argument"
+ """
+ minimal: manage.py builtin commands fail if settings are provided as
+ argument
+ """
args = ["check", "--settings=test_project.settings", "admin_scripts"]
out, err = self.run_manage(args)
self.assertNoOutput(out)
@@ -1126,7 +1138,10 @@ class ManageMinimalSettings(AdminScriptTestCase):
self.assertOutput(err, "No module named '?bad_settings'?", regex=True)
def test_custom_command(self):
- "minimal: manage.py can't execute user commands without appropriate settings"
+ """
+ minimal: manage.py can't execute user commands without appropriate
+ settings
+ """
args = ["noargs_command"]
out, err = self.run_manage(args)
self.assertNoOutput(out)
@@ -1175,7 +1190,10 @@ class ManageAlternateSettings(AdminScriptTestCase):
)
def test_builtin_with_settings(self):
- "alternate: manage.py builtin commands work with settings provided as argument"
+ """
+ alternate: manage.py builtin commands work with settings provided as
+ argument
+ """
args = ["check", "--settings=alternate_settings", "admin_scripts"]
out, err = self.run_manage(args)
self.assertOutput(out, SYSTEM_CHECK_MSG)
@@ -1331,7 +1349,9 @@ class ManageMultipleSettings(AdminScriptTestCase):
self.assertOutput(err, "No module named '?bad_settings'?", regex=True)
def test_custom_command(self):
- "multiple: manage.py can't execute user commands using default settings"
+ """
+ multiple: manage.py can't execute user commands using default settings
+ """
args = ["noargs_command"]
out, err = self.run_manage(args)
self.assertNoOutput(out)
@@ -1709,7 +1729,8 @@ class ManageRunserver(SimpleTestCase):
def test_readonly_database(self):
"""
- runserver.check_migrations() doesn't choke when a database is read-only.
+ runserver.check_migrations() doesn't choke when a database is
+ read-only.
"""
with mock.patch.object(MigrationRecorder, "has_table", return_value=False):
self.cmd.check_migrations()
@@ -1754,7 +1775,9 @@ class ManageRunserver(SimpleTestCase):
self.addCleanup(setattr, registry, "registered_checks", original_checks)
class CustomRunserverCommand(RunserverCommand):
- """Rather than mock run(), raise immediately after system checks run."""
+ """
+ Rather than mock run(), raise immediately after system checks run.
+ """
def check_migrations(self, *args, **kwargs):
raise CustomException
@@ -1921,7 +1944,8 @@ class CommandTypes(AdminScriptTestCase):
def test_version_alternative(self):
"--version is equivalent to version"
args1, args2 = ["version"], ["--version"]
- # It's possible one outputs on stderr and the other on stdout, hence the set
+ # It's possible one outputs on stderr and the other on stdout, hence
+ # the set
self.assertEqual(set(self.run_manage(args1)), set(self.run_manage(args2)))
def test_help(self):
@@ -2136,13 +2160,18 @@ class CommandTypes(AdminScriptTestCase):
self._test_base_command(args, expected_labels, option_a="'x'")
def test_base_command_with_options(self):
- "User BaseCommands can execute with multiple options when a label is provided"
+ """
+ User BaseCommands can execute with multiple options when a label is
+ provided
+ """
args = ["base_command", "testlabel", "-a", "x", "--option_b=y"]
expected_labels = "('testlabel',)"
self._test_base_command(args, expected_labels, option_a="'x'", option_b="'y'")
def test_base_command_with_wrong_option(self):
- "User BaseCommands outputs command usage when wrong option is specified"
+ """
+ User BaseCommands outputs command usage when wrong option is specified
+ """
args = ["base_command", "--invalid"]
out, err = self.run_manage(args)
self.assertNoOutput(out)
@@ -2164,8 +2193,8 @@ class CommandTypes(AdminScriptTestCase):
def test_base_run_from_argv(self):
"""
- Test run_from_argv properly terminates even with custom execute() (#19665)
- Also test proper traceback display.
+ Test run_from_argv properly terminates even with custom execute()
+ (#19665) Also test proper traceback display.
"""
err = StringIO()
command = BaseCommand(stderr=err)
@@ -2292,7 +2321,10 @@ class CommandTypes(AdminScriptTestCase):
self.assertOutput(err, "No installed app with label 'NOT_AN_APP'.")
def test_app_command_some_invalid_app_labels(self):
- "User AppCommands can execute when some of the provided app names are invalid"
+ """
+ User AppCommands can execute when some of the provided app names are
+ invalid
+ """
args = ["app_command", "auth", "NOT_AN_APP"]
out, err = self.run_manage(args)
self.assertOutput(err, "No installed app with label 'NOT_AN_APP'.")
@@ -2316,7 +2348,10 @@ class CommandTypes(AdminScriptTestCase):
self.assertOutput(err, "Enter at least one label")
def test_label_command_multiple_label(self):
- "User LabelCommands are executed multiple times if multiple labels are provided"
+ """
+ User LabelCommands are executed multiple times if multiple labels are
+ provided
+ """
args = ["label_command", "testlabel", "anotherlabel"]
out, err = self.run_manage(args)
self.assertNoOutput(err)
@@ -2558,7 +2593,9 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
)
def test_invalid_project_name(self):
- "Make sure the startproject management command validates a project name"
+ """
+ Make sure the startproject management command validates a project name
+ """
for bad_name in ("7testproject", "../testproject"):
with self.subTest(project_name=bad_name):
args = ["startproject", bad_name]
@@ -2773,7 +2810,10 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
self.assertTrue(os.path.exists(os.path.join(testproject_dir, "run.py")))
def test_file_without_extension(self):
- "Make sure the startproject management command is able to render custom files"
+ """
+ Make sure the startproject management command is able to render custom
+ files
+ """
template_path = os.path.join(custom_templates_dir, "project_template")
args = [
"startproject",
@@ -2845,7 +2885,8 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_destination_missing(self):
"""
- Create the directory when the provided destination directory doesn't exist.
+ Create the directory when the provided destination directory doesn't
+ exist.
"""
template_path = os.path.join(custom_templates_dir, "project_template")
args = [