summaryrefslogtreecommitdiff
path: root/tests/user_commands
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-10-19 21:17:38 +0200
committerClaude Paroz <claude@2xlibre.net>2014-10-20 17:26:00 +0200
commit685edab9da89b54e3e0e7bbc1c9f8b33d3f45969 (patch)
tree64ad3382d9d16c134234d5e4e713f503d95b2ee8 /tests/user_commands
parenta39df37049c6b708924eed1521963929e0694b0c (diff)
Fixed #23685 -- Made call_command skip checks by default
Thanks Loic Bistuer for the report/review and Tim Graham for the review.
Diffstat (limited to 'tests/user_commands')
-rw-r--r--tests/user_commands/management/commands/dance.py5
-rw-r--r--tests/user_commands/tests.py22
2 files changed, 24 insertions, 3 deletions
diff --git a/tests/user_commands/management/commands/dance.py b/tests/user_commands/management/commands/dance.py
index e27042f9d4..0fc82724f4 100644
--- a/tests/user_commands/management/commands/dance.py
+++ b/tests/user_commands/management/commands/dance.py
@@ -15,5 +15,6 @@ class Command(BaseCommand):
example = options["example"]
if example == "raise":
raise CommandError()
- self.stdout.write("I don't feel like dancing %s." % options["style"])
- self.stdout.write(','.join(options.keys()))
+ if options['verbosity'] > 0:
+ self.stdout.write("I don't feel like dancing %s." % options["style"])
+ self.stdout.write(','.join(options.keys()))
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 32224ef277..25d1ad7c33 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -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
@@ -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):