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
b785a80d
Kaydet (Commit)
b785a80d
authored
Agu 25, 2013
tarafından
Ramiro Morales
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added further fixes, tests for #19949/
f33db5a0
.
Thanks Susan Tan. Refs #19949.
üst
51a9a598
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
cached.py
django/template/loaders/cached.py
+5
-1
test_loaders.py
tests/template_tests/test_loaders.py
+8
-2
No files found.
django/template/loaders/cached.py
Dosyayı görüntüle @
b785a80d
...
...
@@ -37,6 +37,9 @@ class Loader(BaseLoader):
return
template_name
def
find_template
(
self
,
name
,
dirs
=
None
):
"""
Helper method. Lookup the template :param name: in all the configured loaders
"""
key
=
self
.
cache_key
(
name
,
dirs
)
try
:
result
=
self
.
find_template_cache
[
key
]
...
...
@@ -53,12 +56,13 @@ class Loader(BaseLoader):
if
result
:
return
result
else
:
self
.
template_cache
[
key
]
=
TemplateDoesNotExist
raise
TemplateDoesNotExist
(
name
)
def
load_template
(
self
,
template_name
,
template_dirs
=
None
):
key
=
self
.
cache_key
(
template_name
,
template_dirs
)
template_tuple
=
self
.
template_cache
.
get
(
key
)
#
cached a
previous failure:
#
A cached
previous failure:
if
template_tuple
is
TemplateDoesNotExist
:
raise
TemplateDoesNotExist
elif
template_tuple
is
None
:
...
...
tests/template_tests/test_loaders.py
Dosyayı görüntüle @
b785a80d
...
...
@@ -129,13 +129,19 @@ class CachedLoader(unittest.TestCase):
self
.
assertNotEqual
(
t1
.
render
(
Context
({})),
t2
.
render
(
Context
({})))
def
test_missing_template_is_cached
(
self
):
"Check that the missing template is cached."
"
#19949 --
Check that the missing template is cached."
template_loader
=
loader
.
find_template_loader
(
settings
.
TEMPLATE_LOADERS
[
0
])
# Empty cache, which may be filled from previous tests.
template_loader
.
reset
()
# Check that 'missing.html' isn't already in cache before 'missing.html' is loaed
# Check that 'missing.html' isn't already in cache before 'missing.html' is loa
d
ed
self
.
assertRaises
(
KeyError
,
lambda
:
template_loader
.
template_cache
[
"missing.html"
])
# Try to load it, it should fail
self
.
assertRaises
(
TemplateDoesNotExist
,
template_loader
.
load_template
,
"missing.html"
)
# Verify that the fact that the missing template, which hasn't been found, has actually
# been cached:
self
.
assertEqual
(
template_loader
.
template_cache
.
get
(
"missing.html"
),
TemplateDoesNotExist
,
"Cached template loader doesn't cache file lookup misses. It should."
)
class
RenderToStringTest
(
unittest
.
TestCase
):
...
...
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