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
c0c1bb9e
Kaydet (Commit)
c0c1bb9e
authored
Eki 31, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoided using private API get_template_from_string.
üst
f2ddc439
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
17 deletions
+12
-17
tests.py
django/contrib/webdesign/tests.py
+2
-2
tests.py
tests/staticfiles_tests/tests.py
+2
-2
test_nodelist.py
tests/template_tests/test_nodelist.py
+6
-11
views.py
tests/test_utils/views.py
+2
-2
No files found.
django/contrib/webdesign/tests.py
Dosyayı görüntüle @
c0c1bb9e
...
...
@@ -3,12 +3,12 @@ from __future__ import unicode_literals
import
unittest
from
django.template
import
loader
,
Context
from
django.template
import
Context
,
Template
class
WebdesignTest
(
unittest
.
TestCase
):
def
test_lorem_tag
(
self
):
t
=
loader
.
get_template_from_string
(
"{
%
load webdesign
%
}{
%
lorem 3 w
%
}"
)
t
=
Template
(
"{
%
load webdesign
%
}{
%
lorem 3 w
%
}"
)
self
.
assertEqual
(
t
.
render
(
Context
({})),
'lorem ipsum dolor'
)
tests/staticfiles_tests/tests.py
Dosyayı görüntüle @
c0c1bb9e
...
...
@@ -8,7 +8,7 @@ import shutil
import
sys
import
unittest
from
django.template
import
loader
,
Context
from
django.template
import
Context
,
Template
from
django.conf
import
settings
from
django.core.cache.backends.base
import
BaseCache
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -97,7 +97,7 @@ class BaseStaticFilesTestCase(object):
def
render_template
(
self
,
template
,
**
kwargs
):
if
isinstance
(
template
,
six
.
string_types
):
template
=
loader
.
get_template_from_string
(
template
)
template
=
Template
(
template
)
return
template
.
render
(
Context
(
kwargs
))
.
strip
()
def
static_template_snippet
(
self
,
path
,
asvar
=
False
):
...
...
tests/template_tests/test_nodelist.py
Dosyayı görüntüle @
c0c1bb9e
from
unittest
import
TestCase
from
django.template
import
VariableNode
,
Context
from
django.template.loader
import
get_template_from_string
from
django.template
import
Context
,
Template
,
VariableNode
from
django.test
import
override_settings
class
NodelistTest
(
TestCase
):
def
test_for
(
self
):
source
=
'{
%
for i in 1
%
}{{ a }}{
%
endfor
%
}'
template
=
get_template_from_string
(
source
)
template
=
Template
(
'{
%
for i in 1
%
}{{ a }}{
%
endfor
%
}'
)
vars
=
template
.
nodelist
.
get_nodes_by_type
(
VariableNode
)
self
.
assertEqual
(
len
(
vars
),
1
)
def
test_if
(
self
):
source
=
'{
%
if x
%
}{{ a }}{
%
endif
%
}'
template
=
get_template_from_string
(
source
)
template
=
Template
(
'{
%
if x
%
}{{ a }}{
%
endif
%
}'
)
vars
=
template
.
nodelist
.
get_nodes_by_type
(
VariableNode
)
self
.
assertEqual
(
len
(
vars
),
1
)
def
test_ifequal
(
self
):
source
=
'{
%
ifequal x y
%
}{{ a }}{
%
endifequal
%
}'
template
=
get_template_from_string
(
source
)
template
=
Template
(
'{
%
ifequal x y
%
}{{ a }}{
%
endifequal
%
}'
)
vars
=
template
.
nodelist
.
get_nodes_by_type
(
VariableNode
)
self
.
assertEqual
(
len
(
vars
),
1
)
def
test_ifchanged
(
self
):
source
=
'{
%
ifchanged x
%
}{{ a }}{
%
endifchanged
%
}'
template
=
get_template_from_string
(
source
)
template
=
Template
(
'{
%
ifchanged x
%
}{{ a }}{
%
endifchanged
%
}'
)
vars
=
template
.
nodelist
.
get_nodes_by_type
(
VariableNode
)
self
.
assertEqual
(
len
(
vars
),
1
)
...
...
@@ -51,7 +46,7 @@ class ErrorIndexTest(TestCase):
'five'
:
5
,
})
for
source
,
expected_error_source_index
in
tests
:
template
=
get_template_from_string
(
source
)
template
=
Template
(
source
)
try
:
template
.
render
(
context
)
except
(
RuntimeError
,
TypeError
)
as
e
:
...
...
tests/test_utils/views.py
Dosyayı görüntüle @
c0c1bb9e
from
django.http
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
from
django.template
import
loader
,
Context
from
django.template
import
Context
,
Template
from
.models
import
Person
...
...
@@ -11,7 +11,7 @@ def get_person(request, pk):
def
no_template_used
(
request
):
template
=
loader
.
get_template_from_string
(
"This is a string-based template"
)
template
=
Template
(
"This is a string-based template"
)
return
HttpResponse
(
template
.
render
(
Context
({})))
...
...
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