Skip to content

Commit d1defa8

Browse files
authored
Slightly simpler indentation (#209)
1 parent c6aa465 commit d1defa8

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

pytest_accept/doctest_plugin.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,10 @@ def pytest_sessionfinish(session, exitstatus):
195195
print(line, file=file)
196196

197197
for current, next in zip_longest(failures, failures[1:]):
198-
# Note that `current.example.indent` no longer works in python 3.13,
199-
# since docstrings are now dedented. So we calculate it from the source.
200-
existing_indent = len(
201-
re.match(r" *", original[next_start_line]).group()
202-
)
198+
# Get the existing indentation from the source line
199+
existing_indent = re.match(r"\s*", original[next_start_line]).group()
203200
snapshot_result = _to_doctest_format(current.got)
204-
indented = textwrap.indent(
205-
snapshot_result, prefix=" " * existing_indent
206-
)
201+
indented = textwrap.indent(snapshot_result, prefix=existing_indent)
207202
for line in indented.splitlines():
208203
print(line, file=file)
209204

0 commit comments

Comments
 (0)