Commits

Anonymous committed 9b66ada

Added one test on python indentation (putting spaces on python commands) - it was just passing! \o/

Comments (0)

Files changed (3)

 
 
 def should_unindent_before(parsed_line):
-    return parsed_line.split()[0].replace(':', '').strip() in unindentation_words_before
+    return parsed_line.strip().split()[0].replace(':', '') in unindentation_words_before
 
 
 def should_unindent_after(parsed_line):
-    return parsed_line.split()[0].replace(':', '').strip() in unindentation_words_after
+    return parsed_line.strip().split()[0].replace(':', '') in unindentation_words_after
 
 
 def parse_python_code(python_code, indentation_level=0):

test_new_template.py

         self.do_it()
 
 
+    def test_some_unindentation_words_and_python_code_with_spaces(self):
+        self.input_ = '''{{def some_function(arg):
+if arg == 10:
+  return True
+ pass
+  something}} test'''
+        self.expected_output = '''def some_function(arg):
+    if arg == 10:
+        return True
+something
+response.write(" test", escape=False)'''
+        self.do_it()
+
 if __name__ == '__main__':
     if len(argv) == 1:
         import new_template
 pass
 more_code_outside_all_blocks}}'''
 
-t1 = timeit.Timer('parse_template(code_to_parse)',
-                 '''from new_template import parse_template
-from __main__ import code_to_parse''').timeit(number=1000)
-print t1
+if __name__ == '__main__':
+    t1 = timeit.Timer('parse_template(code_to_parse)',
+                     '''from new_template import parse_template
+from timetest import code_to_parse''').timeit(number=1000)
+    print t1
 
-t2 = timeit.Timer('parse(code_to_parse)',
-                 '''from template import parse
-from __main__ import code_to_parse''').timeit(number=1000)
-print t2
+    t2 = timeit.Timer('parse(code_to_parse)',
+                     '''from template import parse
+from timetest import code_to_parse''').timeit(number=1000)
+    print t2
 
-print t1 / t2
+    print t1 / t2