mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Removed the app_config.installed flag.
Since applications that aren't installed no longer have an application configuration, it is now always True in practice. Provided an abstraction to temporarily add or remove applications as several tests messed with app_config.installed to achieve this effect. For now this API is _-prefixed because it looks dangerous.
This commit is contained in:
@@ -4,6 +4,7 @@ from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.admindocs import utils
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.apps import app_cache
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
@@ -13,27 +14,18 @@ class MiscTests(TestCase):
|
||||
urls = 'admin_docs.urls'
|
||||
|
||||
def setUp(self):
|
||||
self._old_installed = Site._meta.app_config.installed
|
||||
User.objects.create_superuser('super', None, 'secret')
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
def tearDown(self):
|
||||
Site._meta.app_config.installed = self._old_installed
|
||||
|
||||
@override_settings(
|
||||
SITE_ID=None,
|
||||
INSTALLED_APPS=[app for app in settings.INSTALLED_APPS
|
||||
if app != 'django.contrib.sites'],
|
||||
)
|
||||
def test_no_sites_framework(self):
|
||||
"""
|
||||
Without the sites framework, should not access SITE_ID or Site
|
||||
objects. Deleting settings is fine here as UserSettingsHolder is used.
|
||||
"""
|
||||
Site._meta.app_config.installed = False
|
||||
Site.objects.all().delete()
|
||||
del settings.SITE_ID
|
||||
self.client.get('/admindocs/views/') # should not raise
|
||||
with self.settings(SITE_ID=None), app_cache._without_app('django.contrib.sites'):
|
||||
Site.objects.all().delete()
|
||||
del settings.SITE_ID
|
||||
self.client.get('/admindocs/views/') # should not raise
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
|
||||
|
||||
Reference in New Issue
Block a user