mirror of
https://github.com/django/django.git
synced 2024-11-29 06:03:25 +01:00
Complained on override_settings(INSTALLED_APPS=...).
Currently such overrides aren't reflected in the app cache. It would be possible to handle them. But that doesn't look like a very good API. It makes it complicated to express "add this app" and "remove this app", which are the most common operations on INSTALLED_APPS.
This commit is contained in:
parent
16aae35ca8
commit
517c24bcfa
@ -17,7 +17,7 @@ setting_changed = Signal(providing_args=["setting", "value", "enter"])
|
|||||||
# except for cases where the receiver is related to a contrib app.
|
# except for cases where the receiver is related to a contrib app.
|
||||||
|
|
||||||
# Settings that may not work well when using 'override_settings' (#19031)
|
# Settings that may not work well when using 'override_settings' (#19031)
|
||||||
COMPLEX_OVERRIDE_SETTINGS = set(['DATABASES'])
|
COMPLEX_OVERRIDE_SETTINGS = set(['DATABASES', 'INSTALLED_APPS'])
|
||||||
|
|
||||||
|
|
||||||
@receiver(setting_changed)
|
@receiver(setting_changed)
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
import warnings
|
||||||
|
|
||||||
from django.core.apps import app_cache
|
from django.core.apps import app_cache
|
||||||
from django.core.apps.cache import AppCache
|
from django.core.apps.cache import AppCache
|
||||||
@ -77,11 +78,13 @@ class EggLoadingTest(TestCase):
|
|||||||
# Pretend we're the master app cache to test the population process.
|
# Pretend we're the master app cache to test the population process.
|
||||||
app_cache._apps_loaded = False
|
app_cache._apps_loaded = False
|
||||||
app_cache._models_loaded = False
|
app_cache._models_loaded = False
|
||||||
with override_settings(INSTALLED_APPS=('notexists',)):
|
with warnings.catch_warnings():
|
||||||
with self.assertRaises(ImportError):
|
warnings.filterwarnings("ignore", "Overriding setting INSTALLED_APPS")
|
||||||
app_cache.get_model('notexists', 'nomodel')
|
with override_settings(INSTALLED_APPS=['notexists']):
|
||||||
with self.assertRaises(ImportError):
|
with self.assertRaises(ImportError):
|
||||||
app_cache.get_model('notexists', 'nomodel')
|
app_cache.get_model('notexists', 'nomodel')
|
||||||
|
with self.assertRaises(ImportError):
|
||||||
|
app_cache.get_model('notexists', 'nomodel')
|
||||||
|
|
||||||
|
|
||||||
class GetModelsTest(TestCase):
|
class GetModelsTest(TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user