while pos > 0:
pos -= 1
if last_char is None:
- if buffer[pos] not in " \t\n": # ignore whitespaces
+ if buffer[pos] not in " \t\n#": # ignore whitespaces and comments
last_char = buffer[pos]
else:
# even if we found a non-whitespace character before
output = multiline_input(reader)
self.assertEqual(output, output_code)
+ def test_auto_indent_with_multicomment(self):
+ # fmt: off
+ events = code_to_events(
+ "def f(): ## foo\n"
+ "pass\n\n"
+ )
+
+ output_code = (
+ "def f(): ## foo\n"
+ " pass\n"
+ " "
+ )
+ # fmt: on
+
+ reader = self.prepare_reader(events)
+ output = multiline_input(reader)
+ self.assertEqual(output, output_code)
+
def test_auto_indent_ignore_comments(self):
# fmt: off
events = code_to_events(