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 CommentSyntaxTests(SimpleTestCase):
|
2014-11-12 09:32:44 +08:00
|
|
|
@setup({"comment-syntax01": "{# this is hidden #}hello"})
|
|
|
|
def test_comment_syntax01(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax01")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "hello")
|
|
|
|
|
|
|
|
@setup({"comment-syntax02": "{# this is hidden #}hello{# foo #}"})
|
|
|
|
def test_comment_syntax02(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax02")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "hello")
|
|
|
|
|
|
|
|
@setup({"comment-syntax03": "foo{# {% if %} #}"})
|
|
|
|
def test_comment_syntax03(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax03")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax04": "foo{# {% endblock %} #}"})
|
|
|
|
def test_comment_syntax04(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax04")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax05": "foo{# {% somerandomtag %} #}"})
|
|
|
|
def test_comment_syntax05(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax05")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax06": "foo{# {% #}"})
|
|
|
|
def test_comment_syntax06(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax06")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax07": "foo{# %} #}"})
|
|
|
|
def test_comment_syntax07(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax07")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax08": "foo{# %} #}bar"})
|
|
|
|
def test_comment_syntax08(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax08")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foobar")
|
|
|
|
|
|
|
|
@setup({"comment-syntax09": "foo{# {{ #}"})
|
|
|
|
def test_comment_syntax09(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax09")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax10": "foo{# }} #}"})
|
|
|
|
def test_comment_syntax10(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax10")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax11": "foo{# { #}"})
|
|
|
|
def test_comment_syntax11(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax11")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-syntax12": "foo{# } #}"})
|
|
|
|
def test_comment_syntax12(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-syntax12")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-tag01": "{% comment %}this is hidden{% endcomment %}hello"})
|
|
|
|
def test_comment_tag01(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-tag01")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "hello")
|
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
|
|
|
"comment-tag02": "{% comment %}this is hidden{% endcomment %}"
|
|
|
|
"hello{% comment %}foo{% endcomment %}"
|
2022-02-04 03:24:19 +08:00
|
|
|
}
|
2014-11-12 09:32:44 +08:00
|
|
|
)
|
|
|
|
def test_comment_tag02(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-tag02")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "hello")
|
|
|
|
|
|
|
|
@setup({"comment-tag03": "foo{% comment %} {% if %} {% endcomment %}"})
|
|
|
|
def test_comment_tag03(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-tag03")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-tag04": "foo{% comment %} {% endblock %} {% endcomment %}"})
|
|
|
|
def test_comment_tag04(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-tag04")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|
|
|
|
|
|
|
|
@setup({"comment-tag05": "foo{% comment %} {% somerandomtag %} {% endcomment %}"})
|
|
|
|
def test_comment_tag05(self):
|
2014-12-07 16:43:10 +08:00
|
|
|
output = self.engine.render_to_string("comment-tag05")
|
2014-11-12 09:32:44 +08:00
|
|
|
self.assertEqual(output, "foo")
|