diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py index 993567bf37b..0826dfc9736 100644 --- a/tests/admin_docs/tests.py +++ b/tests/admin_docs/tests.py @@ -11,8 +11,15 @@ from django.test import TestCase, modify_settings, override_settings from .models import Person, Company -@override_settings(ROOT_URLCONF='admin_docs.urls') -class MiscTests(TestCase): +@override_settings( + PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), + ROOT_URLCONF='admin_docs.urls') +@modify_settings(INSTALLED_APPS={'append': 'django.contrib.admindocs'}) +class AdminDocsTestCase(TestCase): + pass + + +class MiscTests(AdminDocsTestCase): def setUp(self): User.objects.create_superuser('super', None, 'secret') @@ -30,10 +37,8 @@ class MiscTests(TestCase): self.client.get('/admindocs/views/') # should not raise -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), - ROOT_URLCONF='admin_docs.urls') @unittest.skipUnless(utils.docutils_is_available, "no docutils installed.") -class AdminDocViewTests(TestCase): +class AdminDocViewTests(AdminDocsTestCase): fixtures = ['data.xml'] def setUp(self): @@ -108,9 +113,7 @@ class AdminDocViewTests(TestCase): utils.docutils_is_available = True -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), - ROOT_URLCONF='admin_docs.urls') -class XViewMiddlewareTest(TestCase): +class XViewMiddlewareTest(AdminDocsTestCase): fixtures = ['data.xml'] def test_xview_func(self): @@ -151,8 +154,7 @@ class XViewMiddlewareTest(TestCase): @unittest.skipUnless(utils.docutils_is_available, "no docutils installed.") -@override_settings(ROOT_URLCONF='admin_docs.urls') -class DefaultRoleTest(TestCase): +class DefaultRoleTest(AdminDocsTestCase): def test_parse_rst(self): """ @@ -187,10 +189,8 @@ class DefaultRoleTest(TestCase): self.assertEqual(parts['fragment'], markup) -@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), - ROOT_URLCONF='admin_docs.urls') @unittest.skipUnless(utils.docutils_is_available, "no docutils installed.") -class TestModelDetailView(TestCase): +class TestModelDetailView(AdminDocsTestCase): """ Tests that various details render correctly """ diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index c8ae5e743c3..e75b86ac4b9 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -30,7 +30,7 @@ from django.forms.utils import ErrorList from django.template.response import TemplateResponse from django.test import TestCase, skipUnlessDBFeature from django.test.utils import patch_logger -from django.test import override_settings +from django.test import modify_settings, override_settings from django.utils import formats from django.utils import translation from django.utils.cache import get_max_age @@ -1491,7 +1491,8 @@ class AdminViewPermissionsTest(TestCase): response = self.client.get(shortcut_url, follow=False) # Can't use self.assertRedirects() because User.get_absolute_url() is silly. self.assertEqual(response.status_code, 302) - self.assertEqual(response.url, 'http://example.com/dummy/foo/') + # Domain may depend on contrib.sites tests also run + six.assertRegex(self, response.url, 'http://(testserver|example.com)/dummy/foo/') def test_has_module_permission(self): """ @@ -4193,6 +4194,7 @@ except ImportError: @unittest.skipUnless(docutils, "no docutils installed.") @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), ROOT_URLCONF="admin_views.urls") +@modify_settings(INSTALLED_APPS={'append': ['django.contrib.admindocs', 'django.contrib.flatpages']}) class AdminDocsTest(TestCase): fixtures = ['admin-views-users.xml'] diff --git a/tests/runtests.py b/tests/runtests.py index 656dfcebe41..e0d5a173f27 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -44,18 +44,10 @@ ALWAYS_INSTALLED_APPS = [ 'django.contrib.contenttypes', 'django.contrib.auth', 'django.contrib.sites', - 'django.contrib.flatpages', - 'django.contrib.redirects', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.admin.apps.SimpleAdminConfig', - 'django.contrib.admindocs', 'django.contrib.staticfiles', - 'django.contrib.humanize', - 'staticfiles_tests', - 'staticfiles_tests.apps.test', - 'staticfiles_tests.apps.no_label', - 'servers.another_app', ] ALWAYS_MIDDLEWARE_CLASSES = ( diff --git a/tests/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py index b7e309e1a78..e135ecfcf82 100644 --- a/tests/staticfiles_tests/test_liveserver.py +++ b/tests/staticfiles_tests/test_liveserver.py @@ -7,7 +7,7 @@ django.test.LiveServerTestCase. import os from django.core.exceptions import ImproperlyConfigured -from django.test import override_settings +from django.test import modify_settings, override_settings from django.utils.six.moves.urllib.request import urlopen from django.utils._os import upath @@ -86,12 +86,11 @@ class StaticLiveServerChecks(LiveServerBase): class StaticLiveServerView(LiveServerBase): - # The test is going to access a static file stored in this application. - available_apps = ['staticfiles_tests.apps.test'] - def urlopen(self, url): return urlopen(self.live_server_url + url) + # The test is going to access a static file stored in this application. + @modify_settings(INSTALLED_APPS={'append': 'staticfiles_tests.apps.test'}) def test_collectstatic_emulation(self): """ Test that StaticLiveServerCase use of staticfiles' serve() allows it to diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py index df9a6ce3a22..ee6b28b3cec 100644 --- a/tests/staticfiles_tests/tests.py +++ b/tests/staticfiles_tests/tests.py @@ -41,6 +41,15 @@ TEST_SETTINGS = { 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.DefaultStorageFinder', ), + 'INSTALLED_APPS': ( + 'django.contrib.contenttypes', + 'django.contrib.auth', + 'django.contrib.admin.apps.SimpleAdminConfig', + 'django.contrib.staticfiles', + 'staticfiles_tests', + 'staticfiles_tests.apps.test', + 'staticfiles_tests.apps.no_label', + ), } from django.contrib.staticfiles.management.commands.collectstatic import Command as CollectstaticCommand @@ -241,8 +250,6 @@ class TestFindStatic(CollectionTestCase, TestDefaults): searched_locations) self.assertIn(os.path.join('django', 'contrib', 'admin', 'static'), searched_locations) - self.assertIn(os.path.join('tests', 'servers', 'another_app', 'static'), - searched_locations) # FileSystemFinder searched locations self.assertIn(TEST_SETTINGS['STATICFILES_DIRS'][1][1], searched_locations) self.assertIn(TEST_SETTINGS['STATICFILES_DIRS'][0], searched_locations)