summaryrefslogtreecommitdiff
path: root/tests/app_loading
diff options
context:
space:
mode:
Diffstat (limited to 'tests/app_loading')
-rw-r--r--tests/app_loading/tests.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py
index 164e363161..a9dc70f4b1 100644
--- a/tests/app_loading/tests.py
+++ b/tests/app_loading/tests.py
@@ -2,9 +2,9 @@ from __future__ import unicode_literals
import os
import sys
-from unittest import TestCase
from django.apps import app_cache
+from django.test import TestCase
from django.utils._os import upath
from django.utils import six
@@ -17,10 +17,9 @@ class EggLoadingTest(TestCase):
# The models need to be removed after the test in order to prevent bad
# interactions with the flush operation in other tests.
- self._old_models = app_cache.app_configs['app_loading'].models.copy()
+ self._old_models = app_cache.all_models['app_loading'].copy()
def tearDown(self):
- app_cache.app_configs['app_loading'].models = self._old_models
app_cache.all_models['app_loading'] = self._old_models
app_cache._get_models_cache = {}
@@ -30,7 +29,7 @@ class EggLoadingTest(TestCase):
"""Models module can be loaded from an app in an egg"""
egg_name = '%s/modelapp.egg' % self.egg_dir
sys.path.append(egg_name)
- with app_cache._with_app('app_with_models'):
+ with self.settings(INSTALLED_APPS=['app_with_models']):
models_module = app_cache.get_app_config('app_with_models').models_module
self.assertIsNotNone(models_module)
@@ -38,7 +37,7 @@ class EggLoadingTest(TestCase):
"""Loading an app from an egg that has no models returns no models (and no error)"""
egg_name = '%s/nomodelapp.egg' % self.egg_dir
sys.path.append(egg_name)
- with app_cache._with_app('app_no_models'):
+ with self.settings(INSTALLED_APPS=['app_no_models']):
models_module = app_cache.get_app_config('app_no_models').models_module
self.assertIsNone(models_module)
@@ -46,7 +45,7 @@ class EggLoadingTest(TestCase):
"""Models module can be loaded from an app located under an egg's top-level package"""
egg_name = '%s/omelet.egg' % self.egg_dir
sys.path.append(egg_name)
- with app_cache._with_app('omelet.app_with_models'):
+ with self.settings(INSTALLED_APPS=['omelet.app_with_models']):
models_module = app_cache.get_app_config('app_with_models').models_module
self.assertIsNotNone(models_module)
@@ -54,7 +53,7 @@ class EggLoadingTest(TestCase):
"""Loading an app with no models from under the top-level egg package generates no error"""
egg_name = '%s/omelet.egg' % self.egg_dir
sys.path.append(egg_name)
- with app_cache._with_app('omelet.app_no_models'):
+ with self.settings(INSTALLED_APPS=['omelet.app_no_models']):
models_module = app_cache.get_app_config('app_no_models').models_module
self.assertIsNone(models_module)
@@ -63,8 +62,8 @@ class EggLoadingTest(TestCase):
egg_name = '%s/brokenapp.egg' % self.egg_dir
sys.path.append(egg_name)
with six.assertRaisesRegex(self, ImportError, 'modelz'):
- with app_cache._with_app('broken_app'):
- app_cache.get_app_config('omelet.app_no_models').models_module
+ with self.settings(INSTALLED_APPS=['broken_app']):
+ pass
class GetModelsTest(TestCase):