Loading django/core/management/__init__.py +2 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ def call_command(name, *args, **options): # Legacy optparse method defaults, _ = parser.parse_args(args=[]) defaults = dict(defaults.__dict__, **options) if 'skip_checks' not in options: defaults['skip_checks'] = True return command.execute(*args, **defaults) Loading docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -634,6 +634,9 @@ Miscellaneous class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the :setting:`CACHES` setting. * By default, :ref:`call_command <call-command>` now always skips the check framework (unless you pass it ``skip_checks=False``). .. _deprecated-features-1.8: Features deprecated in 1.8 Loading tests/user_commands/management/commands/dance.py +3 −2 Original line number Diff line number Diff line Loading @@ -15,5 +15,6 @@ class Command(BaseCommand): example = options["example"] if example == "raise": raise CommandError() if options['verbosity'] > 0: self.stdout.write("I don't feel like dancing %s." % options["style"]) self.stdout.write(','.join(options.keys())) tests/user_commands/tests.py +21 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import warnings from django.db import connection from django.core import management from django.core.management import CommandError from django.core.management import BaseCommand, CommandError from django.core.management.utils import find_command, popen_wrapper from django.test import SimpleTestCase from django.utils import translation Loading Loading @@ -136,6 +136,26 @@ class CommandTests(SimpleTestCase): self.assertTrue(output.startswith(connection.ops.start_transaction_sql())) self.assertTrue(output.endswith(connection.ops.end_transaction_sql())) def test_call_command_no_checks(self): """ By default, call_command should not trigger the check framework, unless specifically asked. """ self.counter = 0 def patched_check(self_, **kwargs): self.counter = self.counter + 1 saved_check = BaseCommand.check BaseCommand.check = patched_check try: management.call_command("dance", verbosity=0) self.assertEqual(self.counter, 0) management.call_command("dance", verbosity=0, skip_checks=False) self.assertEqual(self.counter, 1) finally: BaseCommand.check = saved_check class UtilsTests(SimpleTestCase): Loading Loading
django/core/management/__init__.py +2 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ def call_command(name, *args, **options): # Legacy optparse method defaults, _ = parser.parse_args(args=[]) defaults = dict(defaults.__dict__, **options) if 'skip_checks' not in options: defaults['skip_checks'] = True return command.execute(*args, **defaults) Loading
docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -634,6 +634,9 @@ Miscellaneous class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the :setting:`CACHES` setting. * By default, :ref:`call_command <call-command>` now always skips the check framework (unless you pass it ``skip_checks=False``). .. _deprecated-features-1.8: Features deprecated in 1.8 Loading
tests/user_commands/management/commands/dance.py +3 −2 Original line number Diff line number Diff line Loading @@ -15,5 +15,6 @@ class Command(BaseCommand): example = options["example"] if example == "raise": raise CommandError() if options['verbosity'] > 0: self.stdout.write("I don't feel like dancing %s." % options["style"]) self.stdout.write(','.join(options.keys()))
tests/user_commands/tests.py +21 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import warnings from django.db import connection from django.core import management from django.core.management import CommandError from django.core.management import BaseCommand, CommandError from django.core.management.utils import find_command, popen_wrapper from django.test import SimpleTestCase from django.utils import translation Loading Loading @@ -136,6 +136,26 @@ class CommandTests(SimpleTestCase): self.assertTrue(output.startswith(connection.ops.start_transaction_sql())) self.assertTrue(output.endswith(connection.ops.end_transaction_sql())) def test_call_command_no_checks(self): """ By default, call_command should not trigger the check framework, unless specifically asked. """ self.counter = 0 def patched_check(self_, **kwargs): self.counter = self.counter + 1 saved_check = BaseCommand.check BaseCommand.check = patched_check try: management.call_command("dance", verbosity=0) self.assertEqual(self.counter, 0) management.call_command("dance", verbosity=0, skip_checks=False) self.assertEqual(self.counter, 1) finally: BaseCommand.check = saved_check class UtilsTests(SimpleTestCase): Loading