mirror of
https://github.com/django/django.git
synced 2025-10-17 22:07:29 +00:00
Deprecated load_app().
Adjusted several tests that used it to add apps to the app cache and then attempted to remove them by manipulating attributes directly. Also renamed invalid_models to invalid_models_tests to avoid clashing application labels between the outer and the inner invalid_models applications.
This commit is contained in:
parent
439b364e1e
commit
f25fa9d859
10 changed files with 47 additions and 64 deletions
|
@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
|||
import os
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.apps import app_cache
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, TransactionTestCase
|
||||
|
@ -21,28 +20,21 @@ class ProxyModelInheritanceTests(TransactionTestCase):
|
|||
for the proxied model (as described in #12286). This test creates two dummy
|
||||
apps and calls migrate, then verifies that the table has been created.
|
||||
"""
|
||||
|
||||
available_apps = []
|
||||
available_apps = ['app1', 'app2']
|
||||
|
||||
def setUp(self):
|
||||
self.old_sys_path = sys.path[:]
|
||||
sys.path.append(os.path.dirname(os.path.abspath(upath(__file__))))
|
||||
for app in settings.INSTALLED_APPS:
|
||||
app_cache.load_app(app)
|
||||
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
|
||||
del app_cache.app_configs['app1']
|
||||
del app_cache.app_configs['app2']
|
||||
del app_cache.all_models['app1']
|
||||
del app_cache.all_models['app2']
|
||||
|
||||
def test_table_exists(self):
|
||||
try:
|
||||
app_cache.set_available_apps(settings.INSTALLED_APPS)
|
||||
call_command('migrate', verbosity=0)
|
||||
finally:
|
||||
app_cache.unset_available_apps()
|
||||
call_command('migrate', verbosity=0)
|
||||
from .app1.models import ProxyModel
|
||||
from .app2.models import NiceModel
|
||||
self.assertEqual(NiceModel.objects.all().count(), 0)
|
||||
|
@ -56,7 +48,6 @@ class MultiTableInheritanceProxyTest(TestCase):
|
|||
Deleting an instance of a model proxying a multi-table inherited
|
||||
subclass should cascade delete down the whole inheritance chain (see
|
||||
#18083).
|
||||
|
||||
"""
|
||||
instance = ConcreteModelSubclassProxy.objects.create()
|
||||
instance.delete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue