Skip to content

Commit

Permalink
Slightly simpler indentation (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Dec 8, 2024
1 parent c6aa465 commit d1defa8
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pytest_accept/doctest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,10 @@ def pytest_sessionfinish(session, exitstatus):
print(line, file=file)

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

Expand Down

0 comments on commit d1defa8

Please sign in to comment.