Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Added testcase for bug #196

  • Loading branch information...
commit c02b6f3cc7c3b4bca081097ffeb37bd1884d20bf 1 parent 846bdc1
Richard Eames authored April 15, 2013

Showing 1 changed file with 22 additions and 14 deletions. Show diff stats Hide diff stats

  1. 36  jinja2/testsuite/regression.py
36  jinja2/testsuite/regression.py
@@ -27,7 +27,7 @@ def test_assigned_scoping(self):
27 27
         {%- endfor %}
28 28
         {{- item -}}
29 29
         ''')
30  
-        assert t.render(item=42) == '[1][2][3][4]42'
  30
+        assert t.render(item = 42) == '[1][2][3][4]42'
31 31
 
32 32
         t = env.from_string('''
33 33
         {%- for item in (1, 2, 3, 4) -%}
@@ -75,7 +75,7 @@ def test_closure_scoping(self):
75 75
         {%- endfor %}
76 76
         {{- wrapper -}}
77 77
         ''')
78  
-        assert t.render(wrapper=23) == '[1][2][3][4]23'
  78
+        assert t.render(wrapper = 23) == '[1][2][3][4]23'
79 79
 
80 80
 
81 81
 class BugTestCase(JinjaTestCase):
@@ -87,15 +87,15 @@ def test_keyword_folding(self):
87 87
                .render() == 'teststuff'
88 88
 
89 89
     def test_extends_output_bugs(self):
90  
-        env = Environment(loader=DictLoader({
  90
+        env = Environment(loader = DictLoader({
91 91
             'parent.html': '(({% block title %}{% endblock %}))'
92 92
         }))
93 93
 
94 94
         t = env.from_string('{% if expr %}{% extends "parent.html" %}{% endif %}'
95 95
                             '[[{% block title %}title{% endblock %}]]'
96 96
                             '{% for item in [1, 2, 3] %}({{ item }}){% endfor %}')
97  
-        assert t.render(expr=False) == '[[title]](1)(2)(3)'
98  
-        assert t.render(expr=True) == '((title))'
  97
+        assert t.render(expr = False) == '[[title]](1)(2)(3)'
  98
+        assert t.render(expr = True) == '((title))'
99 99
 
100 100
     def test_urlize_filter_escaping(self):
101 101
         tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')
@@ -121,7 +121,7 @@ def test_loop_call_loop(self):
121 121
         assert tmpl.render().split() == map(unicode, range(1, 11)) * 5
122 122
 
123 123
     def test_weird_inline_comment(self):
124  
-        env = Environment(line_statement_prefix='%')
  124
+        env = Environment(line_statement_prefix = '%')
125 125
         self.assert_raises(TemplateSyntaxError, env.from_string,
126 126
                            '% for item in seq {# missing #}\n...% endfor')
127 127
 
@@ -132,11 +132,11 @@ def test_old_macro_loop_scoping_bug(self):
132 132
 
133 133
     def test_partial_conditional_assignments(self):
134 134
         tmpl = env.from_string('{% if b %}{% set a = 42 %}{% endif %}{{ a }}')
135  
-        assert tmpl.render(a=23) == '23'
136  
-        assert tmpl.render(b=True) == '42'
  135
+        assert tmpl.render(a = 23) == '23'
  136
+        assert tmpl.render(b = True) == '42'
137 137
 
138 138
     def test_stacked_locals_scoping_bug(self):
139  
-        env = Environment(line_statement_prefix='#')
  139
+        env = Environment(line_statement_prefix = '#')
140 140
         t = env.from_string('''\
141 141
 # for j in [1, 2]:
142 142
 #   set x = 1
@@ -157,7 +157,7 @@ def test_stacked_locals_scoping_bug(self):
157 157
 #   print 'D'
158 158
 # endif
159 159
     ''')
160  
-        assert t.render(a=0, b=False, c=42, d=42.0) == '1111C'
  160
+        assert t.render(a = 0, b = False, c = 42, d = 42.0) == '1111C'
161 161
 
162 162
     def test_stacked_locals_scoping_bug_twoframe(self):
163 163
         t = Template('''
@@ -169,7 +169,7 @@ def test_stacked_locals_scoping_bug_twoframe(self):
169 169
             {% endfor %}
170 170
             {{ x }}
171 171
         ''')
172  
-        rv = t.render(foo=[1]).strip()
  172
+        rv = t.render(foo = [1]).strip()
173 173
         assert rv == u'1'
174 174
 
175 175
     def test_call_with_args(self):
@@ -190,7 +190,7 @@ def test_call_with_args(self):
190 190
           </dl>
191 191
         {% endcall %}""")
192 192
 
193  
-        assert [x.strip() for x in t.render(list_of_user=[{
  193
+        assert [x.strip() for x in t.render(list_of_user = [{
194 194
             'username':'apo',
195 195
             'realname':'something else',
196 196
             'description':'test'
@@ -237,7 +237,7 @@ def test_recursive_loop_bug(self):
237 237
         """)
238 238
 
239 239
     def test_correct_prefix_loader_name(self):
240  
-        env = Environment(loader=PrefixLoader({
  240
+        env = Environment(loader = PrefixLoader({
241 241
             'foo':  DictLoader({})
242 242
         }))
243 243
         try:
@@ -246,7 +246,15 @@ def test_correct_prefix_loader_name(self):
246 246
             assert e.name == 'foo/bar.html'
247 247
         else:
248 248
             assert False, 'expected error here'
249  
-
  249
+    
  250
+    def test_strip_white_by_dict(self):
  251
+        tpl1 = Template("""
  252
+        {{-g.a}}
  253
+        """)
  254
+        expected = 'TEST\n        '
  255
+        output = tpl1.render(g = dict(a = 'TEST'))
  256
+        
  257
+        self.assert_equal(expected, output)
250 258
 
251 259
 def suite():
252 260
     suite = unittest.TestSuite()

0 notes on commit c02b6f3

Please sign in to comment.
Something went wrong with that request. Please try again.