Commits

Anonymous committed b9e67cc

Added elif

  • Participants
  • Parent commits b178074

Comments (0)

Files changed (2)

File new_template.py

         return line
 
 def should_unindent(parsed_line):
-    unindentation_words = ('pass', 'else')
+    unindentation_words = ('pass', 'else', 'elif')
     return parsed_line.split()[0].replace(':', '').strip() in unindentation_words
 
 

File test_new_template.py

         self.do_it()
 
 
+    def test_if_elif_and_else_in_python_code_should_indent_only_block_lines(self):
+        self.input_ = '''{{if something:
+some_code
+other_code
+elif other_condition:
+elif_code
+other_elif_code
+else:
+code_on_else
+other_code_on_else
+pass
+code_outside}}'''
+        self.expected_output = '''if something:
+    some_code
+    other_code
+elif other_condition:
+    elif_code
+    other_elif_code
+else:
+    code_on_else
+    other_code_on_else
+code_outside'''
+        self.do_it()
+
+
 if __name__ == '__main__':
     if len(argv) == 1:
         import new_template