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
969e0828
Kaydet (Commit)
969e0828
authored
Ara 27, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for django.template.loader.
Deprecated features aren't tested.
üst
90805b24
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
0 deletions
+107
-0
__init__.py
tests/template_loader/__init__.py
+0
-0
hello.html
...mplate_loader/template_strings/template_loader/hello.html
+1
-0
goodbye.html
tests/template_loader/templates/template_loader/goodbye.html
+1
-0
hello.html
tests/template_loader/templates/template_loader/hello.html
+1
-0
tests.py
tests/template_loader/tests.py
+104
-0
No files found.
tests/template_loader/__init__.py
0 → 100644
Dosyayı görüntüle @
969e0828
tests/template_loader/template_strings/template_loader/hello.html
0 → 100644
Dosyayı görüntüle @
969e0828
Hello! (template strings)
tests/template_loader/templates/template_loader/goodbye.html
0 → 100644
Dosyayı görüntüle @
969e0828
Goodbye! (Django templates)
tests/template_loader/templates/template_loader/hello.html
0 → 100644
Dosyayı görüntüle @
969e0828
Hello! (Django templates)
tests/template_loader/tests.py
0 → 100644
Dosyayı görüntüle @
969e0828
from
django.test
import
override_settings
,
SimpleTestCase
from
django.template
import
TemplateDoesNotExist
from
django.template.loader
import
(
get_template
,
select_template
,
render_to_string
)
@override_settings
(
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.dummy.TemplateStrings'
,
'APP_DIRS'
:
True
,
},
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
}])
class
TemplateLoaderTests
(
SimpleTestCase
):
def
test_get_template_first_engine
(
self
):
template
=
get_template
(
"template_loader/hello.html"
)
self
.
assertEqual
(
template
.
render
(),
"Hello! (template strings)
\n
"
)
def
test_get_template_second_engine
(
self
):
template
=
get_template
(
"template_loader/goodbye.html"
)
self
.
assertEqual
(
template
.
render
(),
"Goodbye! (Django templates)
\n
"
)
def
test_get_template_using_engine
(
self
):
template
=
get_template
(
"template_loader/hello.html"
,
using
=
"django"
)
self
.
assertEqual
(
template
.
render
(),
"Hello! (Django templates)
\n
"
)
def
test_get_template_not_found
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
get_template
(
"template_loader/unknown.html"
)
def
test_select_template_first_engine
(
self
):
template
=
select_template
([
"template_loader/unknown.html"
,
"template_loader/hello.html"
])
self
.
assertEqual
(
template
.
render
(),
"Hello! (template strings)
\n
"
)
def
test_select_template_second_engine
(
self
):
template
=
select_template
([
"template_loader/unknown.html"
,
"template_loader/goodbye.html"
])
self
.
assertEqual
(
template
.
render
(),
"Goodbye! (Django templates)
\n
"
)
def
test_select_template_using_engine
(
self
):
template
=
select_template
([
"template_loader/unknown.html"
,
"template_loader/hello.html"
],
using
=
"django"
)
self
.
assertEqual
(
template
.
render
(),
"Hello! (Django templates)
\n
"
)
def
test_select_template_empty
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
select_template
([])
def
test_select_template_not_found
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
select_template
([
"template_loader/unknown.html"
,
"template_loader/missing.html"
])
def
test_select_template_tries_all_engines_before_names
(
self
):
template
=
select_template
([
"template_loader/goodbye.html"
,
"template_loader/hello.html"
])
self
.
assertEqual
(
template
.
render
(),
"Goodbye! (Django templates)
\n
"
)
def
test_render_to_string_first_engine
(
self
):
content
=
render_to_string
(
"template_loader/hello.html"
)
self
.
assertEqual
(
content
,
"Hello! (template strings)
\n
"
)
def
test_render_to_string_second_engine
(
self
):
content
=
render_to_string
(
"template_loader/goodbye.html"
)
self
.
assertEqual
(
content
,
"Goodbye! (Django templates)
\n
"
)
def
test_render_to_string_using_engine
(
self
):
content
=
render_to_string
(
"template_loader/hello.html"
,
using
=
"django"
)
self
.
assertEqual
(
content
,
"Hello! (Django templates)
\n
"
)
def
test_render_to_string_not_found
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
render_to_string
(
"template_loader/unknown.html"
)
def
test_render_to_string_with_list_first_engine
(
self
):
content
=
render_to_string
([
"template_loader/unknown.html"
,
"template_loader/hello.html"
])
self
.
assertEqual
(
content
,
"Hello! (template strings)
\n
"
)
def
test_render_to_string_with_list_second_engine
(
self
):
content
=
render_to_string
([
"template_loader/unknown.html"
,
"template_loader/goodbye.html"
])
self
.
assertEqual
(
content
,
"Goodbye! (Django templates)
\n
"
)
def
test_render_to_string_with_list_using_engine
(
self
):
content
=
render_to_string
([
"template_loader/unknown.html"
,
"template_loader/hello.html"
],
using
=
"django"
)
self
.
assertEqual
(
content
,
"Hello! (Django templates)
\n
"
)
def
test_render_to_string_with_list_empty
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
render_to_string
([])
def
test_render_to_string_with_list_not_found
(
self
):
with
self
.
assertRaises
(
TemplateDoesNotExist
):
render_to_string
([
"template_loader/unknown.html"
,
"template_loader/missing.html"
])
def
test_render_to_string_with_list_tries_all_engines_before_names
(
self
):
content
=
render_to_string
([
"template_loader/goodbye.html"
,
"template_loader/hello.html"
])
self
.
assertEqual
(
content
,
"Goodbye! (Django templates)
\n
"
)
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