1. from django.test import SimpleTestCase
    
  2. 
    
  3. from ..utils import setup
    
  4. 
    
  5. 
    
  6. class CommentSyntaxTests(SimpleTestCase):
    
  7.     @setup({"comment-syntax01": "{# this is hidden #}hello"})
    
  8.     def test_comment_syntax01(self):
    
  9.         output = self.engine.render_to_string("comment-syntax01")
    
  10.         self.assertEqual(output, "hello")
    
  11. 
    
  12.     @setup({"comment-syntax02": "{# this is hidden #}hello{# foo #}"})
    
  13.     def test_comment_syntax02(self):
    
  14.         output = self.engine.render_to_string("comment-syntax02")
    
  15.         self.assertEqual(output, "hello")
    
  16. 
    
  17.     @setup({"comment-syntax03": "foo{#  {% if %}  #}"})
    
  18.     def test_comment_syntax03(self):
    
  19.         output = self.engine.render_to_string("comment-syntax03")
    
  20.         self.assertEqual(output, "foo")
    
  21. 
    
  22.     @setup({"comment-syntax04": "foo{#  {% endblock %}  #}"})
    
  23.     def test_comment_syntax04(self):
    
  24.         output = self.engine.render_to_string("comment-syntax04")
    
  25.         self.assertEqual(output, "foo")
    
  26. 
    
  27.     @setup({"comment-syntax05": "foo{#  {% somerandomtag %}  #}"})
    
  28.     def test_comment_syntax05(self):
    
  29.         output = self.engine.render_to_string("comment-syntax05")
    
  30.         self.assertEqual(output, "foo")
    
  31. 
    
  32.     @setup({"comment-syntax06": "foo{# {% #}"})
    
  33.     def test_comment_syntax06(self):
    
  34.         output = self.engine.render_to_string("comment-syntax06")
    
  35.         self.assertEqual(output, "foo")
    
  36. 
    
  37.     @setup({"comment-syntax07": "foo{# %} #}"})
    
  38.     def test_comment_syntax07(self):
    
  39.         output = self.engine.render_to_string("comment-syntax07")
    
  40.         self.assertEqual(output, "foo")
    
  41. 
    
  42.     @setup({"comment-syntax08": "foo{# %} #}bar"})
    
  43.     def test_comment_syntax08(self):
    
  44.         output = self.engine.render_to_string("comment-syntax08")
    
  45.         self.assertEqual(output, "foobar")
    
  46. 
    
  47.     @setup({"comment-syntax09": "foo{# {{ #}"})
    
  48.     def test_comment_syntax09(self):
    
  49.         output = self.engine.render_to_string("comment-syntax09")
    
  50.         self.assertEqual(output, "foo")
    
  51. 
    
  52.     @setup({"comment-syntax10": "foo{# }} #}"})
    
  53.     def test_comment_syntax10(self):
    
  54.         output = self.engine.render_to_string("comment-syntax10")
    
  55.         self.assertEqual(output, "foo")
    
  56. 
    
  57.     @setup({"comment-syntax11": "foo{# { #}"})
    
  58.     def test_comment_syntax11(self):
    
  59.         output = self.engine.render_to_string("comment-syntax11")
    
  60.         self.assertEqual(output, "foo")
    
  61. 
    
  62.     @setup({"comment-syntax12": "foo{# } #}"})
    
  63.     def test_comment_syntax12(self):
    
  64.         output = self.engine.render_to_string("comment-syntax12")
    
  65.         self.assertEqual(output, "foo")
    
  66. 
    
  67.     @setup({"comment-tag01": "{% comment %}this is hidden{% endcomment %}hello"})
    
  68.     def test_comment_tag01(self):
    
  69.         output = self.engine.render_to_string("comment-tag01")
    
  70.         self.assertEqual(output, "hello")
    
  71. 
    
  72.     @setup(
    
  73.         {
    
  74.             "comment-tag02": "{% comment %}this is hidden{% endcomment %}"
    
  75.             "hello{% comment %}foo{% endcomment %}"
    
  76.         }
    
  77.     )
    
  78.     def test_comment_tag02(self):
    
  79.         output = self.engine.render_to_string("comment-tag02")
    
  80.         self.assertEqual(output, "hello")
    
  81. 
    
  82.     @setup({"comment-tag03": "foo{% comment %} {% if %} {% endcomment %}"})
    
  83.     def test_comment_tag03(self):
    
  84.         output = self.engine.render_to_string("comment-tag03")
    
  85.         self.assertEqual(output, "foo")
    
  86. 
    
  87.     @setup({"comment-tag04": "foo{% comment %} {% endblock %} {% endcomment %}"})
    
  88.     def test_comment_tag04(self):
    
  89.         output = self.engine.render_to_string("comment-tag04")
    
  90.         self.assertEqual(output, "foo")
    
  91. 
    
  92.     @setup({"comment-tag05": "foo{% comment %} {% somerandomtag %} {% endcomment %}"})
    
  93.     def test_comment_tag05(self):
    
  94.         output = self.engine.render_to_string("comment-tag05")
    
  95.         self.assertEqual(output, "foo")