summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-10 12:02:47 -0500
committerTim Graham <timograham@gmail.com>2015-02-11 10:17:53 -0500
commita0553d1a7cb4f5ecca90650ef9ebad4c44cf6b43 (patch)
treeccbb78a04f66987ddf7dfc58974384c7df3fb704
parentfdcc9c47d51289576ce17849900c96c161273037 (diff)
[1.8.x] Prevented some test commands from needlessly running system checks.
This is a performance optimization and also fixes test errors with the upcoming merge of contrib tests into tests/. The tests failed on MySQL because the models with GeometryField were being checked but the non-GIS MySQL backend didn't know how to handle them. Backport of 197dd4b8f12164f6acebb3b959f9ac2040a40400 from master
-rw-r--r--django/contrib/auth/tests/test_management.py2
-rw-r--r--tests/admin_scripts/tests.py1
-rw-r--r--tests/user_commands/tests.py10
3 files changed, 12 insertions, 1 deletions
diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py
index 6a395bbe7b..cb785ba8fd 100644
--- a/django/contrib/auth/tests/test_management.py
+++ b/django/contrib/auth/tests/test_management.py
@@ -334,6 +334,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
"""
sentinel = object()
command = createsuperuser.Command()
+ command.check = lambda: []
command.execute(
stdin=sentinel,
stdout=six.StringIO(),
@@ -346,6 +347,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
self.assertIs(command.stdin, sentinel)
command = createsuperuser.Command()
+ command.check = lambda: []
command.execute(
stdout=six.StringIO(),
stderr=six.StringIO(),
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 63589963e0..9905630870 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1589,6 +1589,7 @@ class CommandTypes(AdminScriptTestCase):
being executed (#21255).
"""
command = BaseCommand(stderr=StringIO())
+ command.check = lambda: []
command.handle = lambda *args, **kwargs: args
with mock.patch('django.core.management.base.connections') as mock_connections:
command.run_from_argv(['', ''])
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 35de5367ca..eb3b86bd38 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -5,7 +5,7 @@ from django.core import management
from django.core.management import BaseCommand, CommandError, find_commands
from django.core.management.utils import find_command, popen_wrapper
from django.db import connection
-from django.test import SimpleTestCase, ignore_warnings
+from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.test.utils import captured_stderr, captured_stdout, extend_sys_path
from django.utils import translation
from django.utils._os import upath
@@ -13,6 +13,14 @@ from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.six import StringIO
+# A minimal set of apps to avoid system checks running on all apps.
+@override_settings(
+ INSTALLED_APPS=[
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'user_commands',
+ ],
+)
class CommandTests(SimpleTestCase):
def test_command(self):
out = StringIO()