Refactored INSTALLED_APPS overrides.

* Introduced [un]set_installed_apps to handle changes to the
  INSTALLED_APPS setting.
* Refactored [un]set_available_apps to share its implementation
  with [un]set_installed_apps.
* Implemented a receiver to clear some app-related caches.
* Removed test_missing_app as it is basically impossible to reproduce
  this situation with public methods of the new app cache.
This commit is contained in:
Aymeric Augustin 2013-12-23 00:10:53 +01:00
parent 8cff95e937
commit 5891990b6e
8 changed files with 85 additions and 81 deletions

View file

@ -3,11 +3,8 @@ from __future__ import unicode_literals
import os
import sys
from unittest import TestCase
import warnings
from django.apps import app_cache
from django.apps.cache import AppCache
from django.test.utils import override_settings
from django.utils._os import upath
from django.utils import six
@ -69,23 +66,6 @@ class EggLoadingTest(TestCase):
with app_cache._with_app('broken_app'):
app_cache.get_app_config('omelet.app_no_models').models_module
def test_missing_app(self):
"""
Test that repeated app loading doesn't succeed in case there is an
error. Refs #17667.
"""
app_cache = AppCache()
# Pretend we're the master app cache to test the population process.
app_cache._apps_loaded = False
app_cache._models_loaded = False
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "Overriding setting INSTALLED_APPS")
with override_settings(INSTALLED_APPS=['notexists']):
with self.assertRaises(ImportError):
app_cache.get_model('notexists', 'nomodel')
with self.assertRaises(ImportError):
app_cache.get_model('notexists', 'nomodel')
class GetModelsTest(TestCase):
def setUp(self):