2015-04-12 07:41:45 +08:00
|
|
|
from django.template import Context, Engine
|
2014-12-04 04:36:17 +08:00
|
|
|
from django.test import SimpleTestCase
|
2014-11-12 09:32:44 +08:00
|
|
|
|
2014-12-07 16:43:10 +08:00
|
|
|
from ..utils import setup
|
2014-11-12 09:32:44 +08:00
|
|
|
|
|
|
|
|
2014-12-04 04:36:17 +08:00
|
|
|
class IfChangedTagTests(SimpleTestCase):
|
2015-05-09 04:10:36 +08:00
|
|
|
libraries = {"custom": "template_tests.templatetags.custom"}
|
2014-11-12 09:32:44 +08:00
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged01": (
|
|
|
|
"{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged01(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("ifchanged01", {"num": (1, 2, 3)})
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "123")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged02": (
|
|
|
|
"{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged02(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("ifchanged02", {"num": (1, 1, 3)})
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "13")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged03": (
|
|
|
|
"{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged03(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("ifchanged03", {"num": (1, 1, 1)})
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged04": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}"
|
|
|
|
"{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged04(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged04", {"num": (1, 2, 3), "numx": (2, 2, 2)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "122232")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged05": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}"
|
|
|
|
"{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged05(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged05", {"num": (1, 1, 1), "numx": (1, 2, 3)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1123123123")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged06": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}"
|
|
|
|
"{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged06(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged06", {"num": (1, 1, 1), "numx": (2, 2, 2)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1222")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged07": "{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}"
|
|
|
|
"{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}"
|
|
|
|
"{% for y in numy %}{% ifchanged %}{{ y }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged07(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged07", {"num": (1, 1, 1), "numx": (2, 2, 2), "numy": (3, 3, 3)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1233323332333")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged08": "{% for data in datalist %}{% for c,d in data %}"
|
|
|
|
"{% if c %}{% ifchanged %}{{ d }}{% endifchanged %}"
|
|
|
|
"{% endif %}{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged08(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged08",
|
|
|
|
{
|
|
|
|
"datalist": [
|
2014-11-12 09:32:44 +08:00
|
|
|
[(1, "a"), (1, "a"), (0, "b"), (1, "c")],
|
|
|
|
[(0, "a"), (1, "c"), (1, "d"), (1, "d"), (0, "e")],
|
|
|
|
]
|
2022-02-04 03:24:19 +08:00
|
|
|
},
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
self.assertEqual(output, "accd")
|
2022-02-04 03:24:19 +08:00
|
|
|
|
2014-11-12 09:32:44 +08:00
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param01": (
|
|
|
|
"{% for n in num %}{% ifchanged n %}..{% endifchanged %}"
|
|
|
|
"{{ n }}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_param01(self):
|
|
|
|
"""
|
|
|
|
Test one parameter given to ifchanged.
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("ifchanged-param01", {"num": (1, 2, 3)})
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "..1..2..3")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param02": (
|
|
|
|
"{% for n in num %}{% for x in numx %}"
|
|
|
|
"{% ifchanged n %}..{% endifchanged %}{{ x }}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_param02(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-param02", {"num": (1, 2, 3), "numx": (5, 6, 7)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "..567..567..567")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param03": "{% for n in num %}{{ n }}{% for x in numx %}"
|
|
|
|
"{% ifchanged x n %}{{ x }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_param03(self):
|
|
|
|
"""
|
|
|
|
Test multiple parameters to ifchanged.
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-param03", {"num": (1, 1, 2), "numx": (5, 6, 6)}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "156156256")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param04": (
|
|
|
|
"{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}"
|
|
|
|
"{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_param04(self):
|
|
|
|
"""
|
|
|
|
Test a date+hour like construct, where the hour of the last day is
|
|
|
|
the same but the date had changed, so print the hour anyway.
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param04",
|
|
|
|
{"days": [{"hours": [1, 2, 3], "day": 1}, {"hours": [3], "day": 2}]},
|
|
|
|
)
|
|
|
|
self.assertEqual(output, "112323")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param05": (
|
|
|
|
"{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}"
|
|
|
|
"{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}"
|
|
|
|
"{% endfor %}{% endfor %}"
|
2022-02-04 15:08:27 +08:00
|
|
|
)
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_param05(self):
|
|
|
|
"""
|
|
|
|
Logically the same as above, just written with explicit ifchanged
|
|
|
|
for the day.
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-param05",
|
|
|
|
{"days": [{"hours": [1, 2, 3], "day": 1}, {"hours": [3], "day": 2}]},
|
|
|
|
)
|
|
|
|
self.assertEqual(output, "112323")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-else01": "{% for id in ids %}{{ id }}"
|
|
|
|
"{% ifchanged id %}-first{% else %}-other{% endifchanged %}"
|
|
|
|
",{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_else01(self):
|
|
|
|
"""
|
|
|
|
Test the else clause of ifchanged.
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-else01", {"ids": [1, 1, 2, 2, 2, 3]}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1-first,1-other,2-first,2-other,2-other,3-first,")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-else02": "{% for id in ids %}{{ id }}-"
|
2021-08-02 13:51:24 +08:00
|
|
|
'{% ifchanged id %}{% cycle "red" "blue" %}{% else %}gray{% endifchanged %}'
|
2014-11-12 09:32:44 +08:00
|
|
|
",{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_else02(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-else02", {"ids": [1, 1, 2, 2, 2, 3]}
|
|
|
|
)
|
2021-08-02 13:51:24 +08:00
|
|
|
self.assertEqual(output, "1-red,1-gray,2-blue,2-gray,2-gray,3-red,")
|
2014-11-12 09:32:44 +08:00
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-else03": "{% for id in ids %}{{ id }}"
|
2015-03-06 01:38:42 +08:00
|
|
|
'{% ifchanged id %}-{% cycle "red" "blue" %}{% else %}{% endifchanged %}'
|
2014-11-12 09:32:44 +08:00
|
|
|
",{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_else03(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-else03", {"ids": [1, 1, 2, 2, 2, 3]}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "1-red,1,2-blue,2,2,3-red,")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-else04": "{% for id in ids %}"
|
|
|
|
"{% ifchanged %}***{{ id }}*{% else %}...{% endifchanged %}"
|
|
|
|
"{{ forloop.counter }}{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_else04(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string(
|
|
|
|
"ifchanged-else04", {"ids": [1, 1, 2, 2, 2, 3, 4]}
|
|
|
|
)
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "***1*1...2***2*3...4...5***3*6***4*7")
|
|
|
|
|
|
|
|
@setup(
|
2022-02-04 03:24:19 +08:00
|
|
|
{
|
2014-11-12 09:32:44 +08:00
|
|
|
"ifchanged-filter-ws": "{% load custom %}{% for n in num %}"
|
|
|
|
'{% ifchanged n|noop:"x y" %}..{% endifchanged %}{{ n }}'
|
|
|
|
"{% endfor %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_ifchanged_filter_ws(self):
|
|
|
|
"""
|
|
|
|
Test whitespace in filter arguments
|
|
|
|
"""
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("ifchanged-filter-ws", {"num": (1, 2, 3)})
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "..1..2..3")
|
2015-02-22 03:19:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
class IfChangedTests(SimpleTestCase):
|
2015-04-12 07:41:45 +08:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
cls.engine = Engine()
|
2017-01-21 21:13:44 +08:00
|
|
|
super().setUpClass()
|
2015-04-12 07:41:45 +08:00
|
|
|
|
2015-02-22 03:19:08 +08:00
|
|
|
def test_ifchanged_concurrency(self):
|
|
|
|
"""
|
|
|
|
#15849 -- ifchanged should be thread-safe.
|
|
|
|
"""
|
2015-04-12 07:41:45 +08:00
|
|
|
template = self.engine.from_string(
|
|
|
|
"[0{% for x in foo %},{% with var=get_value %}{% ifchanged %}"
|
|
|
|
"{{ var }}{% endifchanged %}{% endwith %}{% endfor %}]"
|
|
|
|
)
|
2015-02-22 03:19:08 +08:00
|
|
|
|
|
|
|
# Using generator to mimic concurrency.
|
|
|
|
# The generator is not passed to the 'for' loop, because it does a list(values)
|
|
|
|
# instead, call gen.next() in the template to control the generator.
|
|
|
|
def gen():
|
|
|
|
yield 1
|
|
|
|
yield 2
|
|
|
|
# Simulate that another thread is now rendering.
|
|
|
|
# When the IfChangeNode stores state at 'self' it stays at '3' and
|
|
|
|
# skip the last yielded value below.
|
|
|
|
iter2 = iter([1, 2, 3])
|
|
|
|
output2 = template.render(
|
|
|
|
Context({"foo": range(3), "get_value": lambda: next(iter2)})
|
2022-02-04 03:24:19 +08:00
|
|
|
)
|
2015-09-12 07:33:12 +08:00
|
|
|
self.assertEqual(
|
|
|
|
output2,
|
|
|
|
"[0,1,2,3]",
|
|
|
|
"Expected [0,1,2,3] in second parallel template, got {}".format(
|
|
|
|
output2
|
2022-02-04 03:24:19 +08:00
|
|
|
),
|
2015-09-12 07:33:12 +08:00
|
|
|
)
|
2015-02-22 03:19:08 +08:00
|
|
|
yield 3
|
|
|
|
|
|
|
|
gen1 = gen()
|
|
|
|
output1 = template.render(
|
|
|
|
Context({"foo": range(3), "get_value": lambda: next(gen1)})
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
output1,
|
|
|
|
"[0,1,2,3]",
|
|
|
|
"Expected [0,1,2,3] in first template, got {}".format(output1),
|
2022-02-04 03:24:19 +08:00
|
|
|
)
|
2015-02-22 03:19:08 +08:00
|
|
|
|
|
|
|
def test_ifchanged_render_once(self):
|
|
|
|
"""
|
|
|
|
#19890. The content of ifchanged template tag was rendered twice.
|
|
|
|
"""
|
2015-04-12 07:41:45 +08:00
|
|
|
template = self.engine.from_string(
|
|
|
|
'{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}'
|
|
|
|
)
|
2015-02-22 03:19:08 +08:00
|
|
|
output = template.render(Context({}))
|
|
|
|
self.assertEqual(output, "1st time")
|
2015-06-04 19:50:07 +08:00
|
|
|
|
|
|
|
def test_include(self):
|
|
|
|
"""
|
|
|
|
#23516 -- This works as a regression test only if the cached loader
|
|
|
|
isn't used. Hence we don't use the @setup decorator.
|
|
|
|
"""
|
|
|
|
engine = Engine(
|
|
|
|
loaders=[
|
|
|
|
(
|
|
|
|
"django.template.loaders.locmem.Loader",
|
|
|
|
{
|
|
|
|
"template": (
|
|
|
|
'{% for x in vars %}{% include "include" %}{% endfor %}'
|
|
|
|
),
|
|
|
|
"include": "{% ifchanged %}{{ x }}{% endifchanged %}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2017-06-02 07:08:59 +08:00
|
|
|
output = engine.render_to_string("template", {"vars": [1, 1, 2, 2, 3, 3]})
|
2015-06-04 19:50:07 +08:00
|
|
|
self.assertEqual(output, "123")
|
2017-04-04 10:29:39 +08:00
|
|
|
|
|
|
|
def test_include_state(self):
|
|
|
|
"""Tests the node state for different IncludeNodes (#27974)."""
|
|
|
|
engine = Engine(
|
|
|
|
loaders=[
|
|
|
|
(
|
|
|
|
"django.template.loaders.locmem.Loader",
|
|
|
|
{
|
|
|
|
"template": (
|
|
|
|
'{% for x in vars %}{% include "include" %}'
|
|
|
|
'{% include "include" %}{% endfor %}'
|
|
|
|
),
|
|
|
|
"include": "{% ifchanged %}{{ x }}{% endifchanged %}",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
)
|
2017-06-02 07:08:59 +08:00
|
|
|
output = engine.render_to_string("template", {"vars": [1, 1, 2, 2, 3, 3]})
|
2017-04-04 10:29:39 +08:00
|
|
|
self.assertEqual(output, "112233")
|