diff --git a/pytest_accept/doctest_plugin.py b/pytest_accept/doctest_plugin.py index cf1b0af..d652f55 100644 --- a/pytest_accept/doctest_plugin.py +++ b/pytest_accept/doctest_plugin.py @@ -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)