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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.