Loading django/contrib/admin/sites.py +7 −9 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from django.contrib.auth import logout as auth_logout, REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import csrf_protect from django.db.models.base import ModelBase from django.core.apps import app_cache from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.core.urlresolvers import reverse, NoReverseMatch from django.template.response import TemplateResponse Loading Loading @@ -156,20 +157,17 @@ class AdminSite(object): """ Check that all things needed to run the admin have been correctly installed. The default implementation checks that LogEntry, ContentType and the auth context processor are installed. The default implementation checks that admin and contenttypes apps are installed, as well as the auth context processor. """ from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType if not LogEntry._meta.installed: app_cache.populate_apps() if not app_cache.has_app('django.contrib.admin'): raise ImproperlyConfigured("Put 'django.contrib.admin' in your " "INSTALLED_APPS setting in order to use the admin application.") if not ContentType._meta.installed: if not app_cache.has_app('django.contrib.contenttypes'): raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in " "your INSTALLED_APPS setting in order to use the admin application.") if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or 'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS): if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS: raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' " "in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.") Loading tests/migrations/test_writer.py +7 −8 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ from django.core.apps import app_cache from django.core.validators import RegexValidator, EmailValidator from django.db import models, migrations from django.db.migrations.writer import MigrationWriter from django.test import TestCase, override_settings from django.test import TestCase from django.utils import six from django.utils.deconstruct import deconstructible from django.utils.translation import ugettext_lazy as _ Loading Loading @@ -122,7 +122,6 @@ class WriterTests(TestCase): base_dir = os.path.dirname(os.path.dirname(__file__)) with override_settings(INSTALLED_APPS=test_apps): for app in test_apps: with app_cache._with_app(app): migration = migrations.Migration('0001_initial', app.split('.')[-1]) Loading tests/proxy_model_inheritance/tests.py +8 −10 Original line number Diff line number Diff line Loading @@ -13,7 +13,8 @@ from .models import (ConcreteModel, ConcreteModelSubclass, ConcreteModelSubclassProxy) @override_settings(INSTALLED_APPS=('app1', 'app2')) # Required for available_apps. @override_settings(INSTALLED_APPS=['app1', 'app2']) class ProxyModelInheritanceTests(TransactionTestCase): """ Proxy model inheritance across apps can result in migrate not creating the table Loading @@ -25,15 +26,12 @@ class ProxyModelInheritanceTests(TransactionTestCase): def setUp(self): self.old_sys_path = sys.path[:] sys.path.append(os.path.dirname(os.path.abspath(upath(__file__)))) self._with_app1 = app_cache._begin_with_app('app1') self._with_app2 = app_cache._begin_with_app('app2') def tearDown(self): app_cache._end_with_app(self._with_app1) app_cache._end_with_app(self._with_app2) sys.path = self.old_sys_path def test_table_exists(self): with app_cache._with_app('app1'), app_cache._with_app('app2'): call_command('migrate', verbosity=0) from .app1.models import ProxyModel from .app2.models import NiceModel Loading tests/staticfiles_tests/tests.py +3 −3 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class TestCollectionDryRun(CollectionTestCase, TestNoFilesCreated): class TestCollectionFilesOverride(CollectionTestCase): """ Test overriding duplicated files by ``collectstatic`` management command. Check for proper handling of apps order in INSTALLED_APPS even if file modification Check for proper handling of apps order in installed apps even if file modification dates are in different order: 'staticfiles_tests.apps.test', Loading @@ -314,7 +314,7 @@ class TestCollectionFilesOverride(CollectionTestCase): # prepare duplicate of file2.txt from no_label app # this file will have modification time older than no_label/static/file2.txt # anyway it should be taken to STATIC_ROOT because 'test' app is before # 'no_label' app in INSTALLED_APPS # 'no_label' app in installed apps self.testfile_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'file2.txt') with open(self.testfile_path, 'w+') as f: f.write('duplicate of file2.txt') Loading @@ -340,7 +340,7 @@ class TestCollectionFilesOverride(CollectionTestCase): self.assertFileContains('file2.txt', 'duplicate of file2.txt') # and now change modification time of no_label/static/file2.txt # test app is first in INSTALLED_APPS so file2.txt should remain unmodified # test app is first in installed apps so file2.txt should remain unmodified mtime = os.path.getmtime(self.testfile_path) atime = os.path.getatime(self.testfile_path) os.utime(self.orig_path, (mtime + 1, atime + 1)) Loading tests/utils_tests/test_autoreload.py +8 −5 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import os from django import conf from django.contrib import admin from django.core.apps import app_cache from django.test import TestCase, override_settings from django.utils.autoreload import gen_filenames Loading @@ -27,7 +28,6 @@ class TestFilenameGenerator(TestCase): self.assertIn(os.path.join(LOCALE_PATH, 'nl', 'LC_MESSAGES', 'django.mo'), filenames) @override_settings(INSTALLED_APPS=()) def test_project_root_locale(self): """ Test that gen_filenames also yields from the current directory (project Loading @@ -36,6 +36,9 @@ class TestFilenameGenerator(TestCase): old_cwd = os.getcwd() os.chdir(os.path.dirname(__file__)) try: # Remove the current app from the app cache to guarantee that the # files will be found thanks to the current working directory. with app_cache._empty(): filenames = list(gen_filenames()) self.assertIn( os.path.join(LOCALE_PATH, 'nl', 'LC_MESSAGES', 'django.mo'), Loading @@ -43,11 +46,11 @@ class TestFilenameGenerator(TestCase): finally: os.chdir(old_cwd) @override_settings(INSTALLED_APPS=('django.contrib.admin',)) def test_app_locales(self): """ Test that gen_filenames also yields from INSTALLED_APPS locales. Test that gen_filenames also yields from locale dirs in installed apps. """ with app_cache._empty(), app_cache._with_app('django.contrib.admin'): filenames = list(gen_filenames()) self.assertIn(os.path.join(os.path.dirname(admin.__file__), 'locale', 'nl', 'LC_MESSAGES', 'django.mo'), Loading Loading
django/contrib/admin/sites.py +7 −9 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from django.contrib.auth import logout as auth_logout, REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import csrf_protect from django.db.models.base import ModelBase from django.core.apps import app_cache from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.core.urlresolvers import reverse, NoReverseMatch from django.template.response import TemplateResponse Loading Loading @@ -156,20 +157,17 @@ class AdminSite(object): """ Check that all things needed to run the admin have been correctly installed. The default implementation checks that LogEntry, ContentType and the auth context processor are installed. The default implementation checks that admin and contenttypes apps are installed, as well as the auth context processor. """ from django.contrib.admin.models import LogEntry from django.contrib.contenttypes.models import ContentType if not LogEntry._meta.installed: app_cache.populate_apps() if not app_cache.has_app('django.contrib.admin'): raise ImproperlyConfigured("Put 'django.contrib.admin' in your " "INSTALLED_APPS setting in order to use the admin application.") if not ContentType._meta.installed: if not app_cache.has_app('django.contrib.contenttypes'): raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in " "your INSTALLED_APPS setting in order to use the admin application.") if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or 'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS): if 'django.contrib.auth.context_processors.auth' not in settings.TEMPLATE_CONTEXT_PROCESSORS: raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' " "in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.") Loading
tests/migrations/test_writer.py +7 −8 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ from django.core.apps import app_cache from django.core.validators import RegexValidator, EmailValidator from django.db import models, migrations from django.db.migrations.writer import MigrationWriter from django.test import TestCase, override_settings from django.test import TestCase from django.utils import six from django.utils.deconstruct import deconstructible from django.utils.translation import ugettext_lazy as _ Loading Loading @@ -122,7 +122,6 @@ class WriterTests(TestCase): base_dir = os.path.dirname(os.path.dirname(__file__)) with override_settings(INSTALLED_APPS=test_apps): for app in test_apps: with app_cache._with_app(app): migration = migrations.Migration('0001_initial', app.split('.')[-1]) Loading
tests/proxy_model_inheritance/tests.py +8 −10 Original line number Diff line number Diff line Loading @@ -13,7 +13,8 @@ from .models import (ConcreteModel, ConcreteModelSubclass, ConcreteModelSubclassProxy) @override_settings(INSTALLED_APPS=('app1', 'app2')) # Required for available_apps. @override_settings(INSTALLED_APPS=['app1', 'app2']) class ProxyModelInheritanceTests(TransactionTestCase): """ Proxy model inheritance across apps can result in migrate not creating the table Loading @@ -25,15 +26,12 @@ class ProxyModelInheritanceTests(TransactionTestCase): def setUp(self): self.old_sys_path = sys.path[:] sys.path.append(os.path.dirname(os.path.abspath(upath(__file__)))) self._with_app1 = app_cache._begin_with_app('app1') self._with_app2 = app_cache._begin_with_app('app2') def tearDown(self): app_cache._end_with_app(self._with_app1) app_cache._end_with_app(self._with_app2) sys.path = self.old_sys_path def test_table_exists(self): with app_cache._with_app('app1'), app_cache._with_app('app2'): call_command('migrate', verbosity=0) from .app1.models import ProxyModel from .app2.models import NiceModel Loading
tests/staticfiles_tests/tests.py +3 −3 Original line number Diff line number Diff line Loading @@ -298,7 +298,7 @@ class TestCollectionDryRun(CollectionTestCase, TestNoFilesCreated): class TestCollectionFilesOverride(CollectionTestCase): """ Test overriding duplicated files by ``collectstatic`` management command. Check for proper handling of apps order in INSTALLED_APPS even if file modification Check for proper handling of apps order in installed apps even if file modification dates are in different order: 'staticfiles_tests.apps.test', Loading @@ -314,7 +314,7 @@ class TestCollectionFilesOverride(CollectionTestCase): # prepare duplicate of file2.txt from no_label app # this file will have modification time older than no_label/static/file2.txt # anyway it should be taken to STATIC_ROOT because 'test' app is before # 'no_label' app in INSTALLED_APPS # 'no_label' app in installed apps self.testfile_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'file2.txt') with open(self.testfile_path, 'w+') as f: f.write('duplicate of file2.txt') Loading @@ -340,7 +340,7 @@ class TestCollectionFilesOverride(CollectionTestCase): self.assertFileContains('file2.txt', 'duplicate of file2.txt') # and now change modification time of no_label/static/file2.txt # test app is first in INSTALLED_APPS so file2.txt should remain unmodified # test app is first in installed apps so file2.txt should remain unmodified mtime = os.path.getmtime(self.testfile_path) atime = os.path.getatime(self.testfile_path) os.utime(self.orig_path, (mtime + 1, atime + 1)) Loading
tests/utils_tests/test_autoreload.py +8 −5 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import os from django import conf from django.contrib import admin from django.core.apps import app_cache from django.test import TestCase, override_settings from django.utils.autoreload import gen_filenames Loading @@ -27,7 +28,6 @@ class TestFilenameGenerator(TestCase): self.assertIn(os.path.join(LOCALE_PATH, 'nl', 'LC_MESSAGES', 'django.mo'), filenames) @override_settings(INSTALLED_APPS=()) def test_project_root_locale(self): """ Test that gen_filenames also yields from the current directory (project Loading @@ -36,6 +36,9 @@ class TestFilenameGenerator(TestCase): old_cwd = os.getcwd() os.chdir(os.path.dirname(__file__)) try: # Remove the current app from the app cache to guarantee that the # files will be found thanks to the current working directory. with app_cache._empty(): filenames = list(gen_filenames()) self.assertIn( os.path.join(LOCALE_PATH, 'nl', 'LC_MESSAGES', 'django.mo'), Loading @@ -43,11 +46,11 @@ class TestFilenameGenerator(TestCase): finally: os.chdir(old_cwd) @override_settings(INSTALLED_APPS=('django.contrib.admin',)) def test_app_locales(self): """ Test that gen_filenames also yields from INSTALLED_APPS locales. Test that gen_filenames also yields from locale dirs in installed apps. """ with app_cache._empty(), app_cache._with_app('django.contrib.admin'): filenames = list(gen_filenames()) self.assertIn(os.path.join(os.path.dirname(admin.__file__), 'locale', 'nl', 'LC_MESSAGES', 'django.mo'), Loading