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
86367a11
Kaydet (Commit)
86367a11
authored
Eki 04, 2017
tarafından
Mads Jensen
Kaydeden (comit)
Tim Graham
Eki 05, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for invalid {% for %} usage and ForLoop.__repr__().
üst
ee7ab1b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
test_for.py
tests/template_tests/syntax_tests/test_for.py
+19
-0
No files found.
tests/template_tests/syntax_tests/test_for.py
Dosyayı görüntüle @
86367a11
from
django.template
import
TemplateSyntaxError
from
django.template.defaulttags
import
ForNode
from
django.test
import
SimpleTestCase
from
..utils
import
setup
...
...
@@ -197,3 +198,21 @@ class ForTagTests(SimpleTestCase):
},
})
self
.
assertEqual
(
output
,
'two:2,four:4,_six:6,eight:8,'
)
@setup
({
'invalid_for_loop'
:
'{
%
for x items
%
}{{ x }}{
%
endfor
%
}'
})
def
test_invalid_arg
(
self
):
msg
=
"'for' statements should have at least four words: for x items"
with
self
.
assertRaisesMessage
(
TemplateSyntaxError
,
msg
):
self
.
engine
.
render_to_string
(
'invalid_for_loop'
,
{
'items'
:
(
1
,
2
)})
@setup
({
'invalid_for_loop'
:
'{
%
for x from items
%
}{{ x }}{
%
endfor
%
}'
})
def
test_invalid_in_keyword
(
self
):
msg
=
"'for' statements should use the format 'for x in y': for x from items"
with
self
.
assertRaisesMessage
(
TemplateSyntaxError
,
msg
):
self
.
engine
.
render_to_string
(
'invalid_for_loop'
,
{
'items'
:
(
1
,
2
)})
class
ForNodeTests
(
SimpleTestCase
):
def
test_repr
(
self
):
node
=
ForNode
(
'x'
,
'sequence'
,
is_reversed
=
True
,
nodelist_loop
=
[
'val'
],
nodelist_empty
=
[
'val2'
])
self
.
assertEqual
(
repr
(
node
),
'<ForNode: for x in sequence, tail_len: 1 reversed>'
)
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