Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified call_command() calls. #17115

Merged
merged 1 commit into from Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion django/core/management/commands/testserver.py
Expand Up @@ -45,7 +45,7 @@ def handle(self, *fixture_labels, **options):
)

# Import the fixture data into the test database.
call_command("loaddata", *fixture_labels, **{"verbosity": verbosity})
call_command("loaddata", *fixture_labels, verbosity=verbosity)

# Run the development server. Turn off auto-reloading because it causes
# a strange error -- it causes this handle() method to be called
Expand Down
9 changes: 3 additions & 6 deletions django/test/testcases.py
Expand Up @@ -1085,11 +1085,7 @@ def _fixture_setup(self):
apps.set_available_apps(self.available_apps)

if self.fixtures:
# We have to use this slightly awkward syntax due to the fact
# that we're using *args and **kwargs together.
felixxm marked this conversation as resolved.
Show resolved Hide resolved
call_command(
"loaddata", *self.fixtures, **{"verbosity": 0, "database": db_name}
)
call_command("loaddata", *self.fixtures, verbosity=0, database=db_name)

def _should_reload_connections(self):
return True
Expand Down Expand Up @@ -1282,7 +1278,8 @@ def setUpClass(cls):
call_command(
"loaddata",
*cls.fixtures,
**{"verbosity": 0, "database": db_name},
verbosity=0,
database=db_name,
)
except Exception:
cls._rollback_atomics(cls.cls_atomics)
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/django-admin.txt
Expand Up @@ -2075,7 +2075,7 @@ Running management commands from your code

.. function:: django.core.management.call_command(name, *args, **options)

To call a management command from code use ``call_command``.
To call a management command from code use ``call_command()``.

``name``
the name of the command to call or a command object. Passing the name is
Expand Down
5 changes: 3 additions & 2 deletions tests/user_commands/tests.py
Expand Up @@ -351,7 +351,8 @@ def test_required_list_option(self):
management.call_command(
command,
*args,
**{**kwargs, "stdout": out},
**kwargs,
stdout=out,
)
self.assertIn("foo_list=[1, 2]", out.getvalue())

Expand All @@ -378,7 +379,7 @@ def test_required_const_options(self):
)
self.assertIn(expected_output, out.getvalue())
out.truncate(0)
management.call_command("required_constant_option", **{**args, "stdout": out})
management.call_command("required_constant_option", **args, stdout=out)
self.assertIn(expected_output, out.getvalue())

def test_subparser(self):
Expand Down