mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Simplified call_command() calls.
This commit is contained in:
parent
a564f44350
commit
89c8c2e831
@ -45,7 +45,7 @@ class Command(BaseCommand):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Import the fixture data into the test database.
|
# 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
|
# Run the development server. Turn off auto-reloading because it causes
|
||||||
# a strange error -- it causes this handle() method to be called
|
# a strange error -- it causes this handle() method to be called
|
||||||
|
@ -1085,11 +1085,7 @@ class TransactionTestCase(SimpleTestCase):
|
|||||||
apps.set_available_apps(self.available_apps)
|
apps.set_available_apps(self.available_apps)
|
||||||
|
|
||||||
if self.fixtures:
|
if self.fixtures:
|
||||||
# We have to use this slightly awkward syntax due to the fact
|
call_command("loaddata", *self.fixtures, verbosity=0, database=db_name)
|
||||||
# that we're using *args and **kwargs together.
|
|
||||||
call_command(
|
|
||||||
"loaddata", *self.fixtures, **{"verbosity": 0, "database": db_name}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _should_reload_connections(self):
|
def _should_reload_connections(self):
|
||||||
return True
|
return True
|
||||||
@ -1282,7 +1278,8 @@ class TestCase(TransactionTestCase):
|
|||||||
call_command(
|
call_command(
|
||||||
"loaddata",
|
"loaddata",
|
||||||
*cls.fixtures,
|
*cls.fixtures,
|
||||||
**{"verbosity": 0, "database": db_name},
|
verbosity=0,
|
||||||
|
database=db_name,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
cls._rollback_atomics(cls.cls_atomics)
|
cls._rollback_atomics(cls.cls_atomics)
|
||||||
|
@ -2075,7 +2075,7 @@ Running management commands from your code
|
|||||||
|
|
||||||
.. function:: django.core.management.call_command(name, *args, **options)
|
.. 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``
|
``name``
|
||||||
the name of the command to call or a command object. Passing the name is
|
the name of the command to call or a command object. Passing the name is
|
||||||
|
@ -351,7 +351,8 @@ class CommandTests(SimpleTestCase):
|
|||||||
management.call_command(
|
management.call_command(
|
||||||
command,
|
command,
|
||||||
*args,
|
*args,
|
||||||
**{**kwargs, "stdout": out},
|
**kwargs,
|
||||||
|
stdout=out,
|
||||||
)
|
)
|
||||||
self.assertIn("foo_list=[1, 2]", out.getvalue())
|
self.assertIn("foo_list=[1, 2]", out.getvalue())
|
||||||
|
|
||||||
@ -378,7 +379,7 @@ class CommandTests(SimpleTestCase):
|
|||||||
)
|
)
|
||||||
self.assertIn(expected_output, out.getvalue())
|
self.assertIn(expected_output, out.getvalue())
|
||||||
out.truncate(0)
|
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())
|
self.assertIn(expected_output, out.getvalue())
|
||||||
|
|
||||||
def test_subparser(self):
|
def test_subparser(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user