Permalink
Browse files

Used available_apps for some plain TestCases

Some tests test explicitly syncdb which results in nonnecessary
permission and contenttype creation.
  • Loading branch information...
1 parent 02bdd9a commit b101db2d5f738535aef18db73db2a156666346e3 @akaariai committed Jun 10, 2013
@@ -27,6 +27,11 @@
class TestFixtures(TestCase):
+ available_apps = [
+ 'fixtures_regress',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ ]
def animal_pre_save_check(self, signal, sender, instance, **kwargs):
self.pre_save_checks.append(
@@ -455,6 +460,11 @@ def test_loaddata_not_existant_fixture_file(self):
class NaturalKeyFixtureTests(TestCase):
+ available_apps = [
+ 'fixtures_regress',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ ]
def test_nk_deserialize(self):
"""
@@ -1001,6 +1001,9 @@ def test_router_init_arg(self):
class RouterTestCase(TestCase):
multi_db = True
+ available_apps = [
+ 'multiple_database'
+ ]
def setUp(self):
# Make the 'other' database appear to be a slave of the 'default'
@@ -1944,6 +1947,8 @@ def allow_syncdb(self, db, model):
class SyncDBTestCase(TestCase):
multi_db = True
+ available_apps = ['multiple_database', 'django.contrib.contenttypes',
+ 'django.contrib.auth']
def test_syncdb_to_other_database(self):
"""Regression test for #16039: syncdb with --database option."""
@@ -14,15 +14,15 @@
ConcreteModelSubclassProxy)
-@override_settings(INSTALLED_APPS=('app1', 'app2'))
+@override_settings(INSTALLED_APPS=('app1', 'app2', 'proxy_model_inheritance'))
class ProxyModelInheritanceTests(TransactionTestCase):
"""
Proxy model inheritance across apps can result in syncdb not creating the table
for the proxied model (as described in #12286). This test creates two dummy
apps and calls syncdb, then verifies that the table has been created.
"""
- available_apps = []
+ available_apps = ['app1', 'app2', 'proxy_model_inheritance']
def setUp(self):
self.old_sys_path = sys.path[:]
@@ -40,11 +40,8 @@ def tearDown(self):
del cache.app_models['app2']
def test_table_exists(self):
- try:
- cache.set_available_apps(settings.INSTALLED_APPS)
- call_command('syncdb', verbosity=0)
- finally:
- cache.unset_available_apps()
+ cache.set_available_apps(settings.INSTALLED_APPS)
+ call_command('syncdb', verbosity=0)
from .app1.models import ProxyModel
from .app2.models import NiceModel
self.assertEqual(NiceModel.objects.all().count(), 0)
@@ -13,6 +13,9 @@
class SwappableModelTests(TestCase):
+ available_apps = ['swappable_models', 'django.contrib.auth',
+ 'django.contrib.contenttypes']
+
def setUp(self):
# This test modifies the installed apps, so we need to make sure
# we're not dealing with a cached app list.
@@ -55,6 +55,8 @@ def __call__(self, signal, sender, **kwargs):
class SyncdbSignalTests(TestCase):
+ available_apps = ['syncdb_signals', 'shared_models']
+
def test_pre_syncdb_call_time(self):
self.assertEqual(pre_syncdb_receiver.call_counter, 1)
@@ -9,7 +9,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django import db
-from django.test import runner, TransactionTestCase, skipUnlessDBFeature
+from django.test import runner, TransactionTestCase, skipUnlessDBFeature, TestCase as DjangoTestCase
from django.test.simple import DjangoTestSuiteRunner, get_tests
from django.test.testcases import connections_support_transactions
from django.utils import unittest
@@ -238,7 +238,8 @@ def test_import_error(self):
self.assertRaises(ImportError, get_tests, module)
-class Sqlite3InMemoryTestDbs(unittest.TestCase):
+class Sqlite3InMemoryTestDbs(DjangoTestCase):
+ available_apps = ['test_runner']
@unittest.skipUnless(all(db.connections[conn].vendor == 'sqlite' for conn in db.connections),
"This is a sqlite-specific issue")

0 comments on commit b101db2

Please sign in to comment.