mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Added check_apps_ready() to Apps.get_containing_app_config()
This commit is contained in:
parent
540ca563de
commit
9033003d97
2 changed files with 14 additions and 4 deletions
|
@ -8,7 +8,7 @@ from unittest import skipUnless
|
|||
from django.apps import AppConfig, apps
|
||||
from django.apps.registry import Apps
|
||||
from django.contrib.admin.models import LogEntry
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
|
||||
from django.db import models
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test.utils import extend_sys_path
|
||||
|
@ -247,6 +247,18 @@ class AppsTests(TestCase):
|
|||
"Conflicting 'southponies' models in application 'apps':.*"):
|
||||
type(str("SouthPonies"), (models.Model,), body)
|
||||
|
||||
def test_get_containing_app_config_apps_not_ready(self):
|
||||
"""
|
||||
apps.get_containing_app_config() should raise an exception if
|
||||
apps.apps_ready isn't True.
|
||||
"""
|
||||
apps.apps_ready = False
|
||||
try:
|
||||
with self.assertRaisesMessage(AppRegistryNotReady, "Apps aren't loaded yet"):
|
||||
apps.get_containing_app_config('foo')
|
||||
finally:
|
||||
apps.apps_ready = True
|
||||
|
||||
|
||||
class Stub(object):
|
||||
def __init__(self, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue