Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
9033003d
Kaydet (Commit)
9033003d
authored
Şub 08, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added check_apps_ready() to Apps.get_containing_app_config()
üst
540ca563
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
registry.py
django/apps/registry.py
+1
-3
tests.py
tests/apps/tests.py
+13
-1
No files found.
django/apps/registry.py
Dosyayı görüntüle @
9033003d
...
...
@@ -227,9 +227,7 @@ class Apps(object):
Returns the app config for the inner application in case of nesting.
Returns None if the object isn't in any registered app config.
"""
# In Django 1.7 and 1.8, it's allowed to call this method at import
# time, even while the registry is being populated. In Django 1.9 and
# later, that should be forbidden with `self.check_apps_ready()`.
self
.
check_apps_ready
()
candidates
=
[]
for
app_config
in
self
.
app_configs
.
values
():
if
object_name
.
startswith
(
app_config
.
name
):
...
...
tests/apps/tests.py
Dosyayı görüntüle @
9033003d
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment