We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9ad726a + 77235e2 commit bb9683dCopy full SHA for bb9683d
src/_pytest/_code/code.py
@@ -725,11 +725,11 @@ def get_source(
725
) -> List[str]:
726
"""Return formatted and marked up source lines."""
727
lines = []
728
- if source is not None and line_index < 0:
729
- line_index += len(source.lines)
730
- if source is None or line_index >= len(source.lines) or line_index < 0:
+ if source is None or line_index >= len(source.lines):
731
source = Source("???")
732
line_index = 0
+ if line_index < 0:
+ line_index += len(source)
733
space_prefix = " "
734
if short:
735
lines.append(space_prefix + source.lines[line_index].strip())
0 commit comments