From 3693fb8ef69b09a5359ddf1f5d171849b7194a75 Mon Sep 17 00:00:00 2001 From: Elias Freider Date: Thu, 28 Nov 2024 10:13:06 +0100 Subject: [PATCH] Ugly quickfix for broken tracebacks --- src/pytest_markdown_docs/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pytest_markdown_docs/plugin.py b/src/pytest_markdown_docs/plugin.py index cad6b4e..ad78ac0 100644 --- a/src/pytest_markdown_docs/plugin.py +++ b/src/pytest_markdown_docs/plugin.py @@ -115,7 +115,9 @@ def repr_failure( True # start capturing frames the first time we enter user code ) line = ( - rawlines[frame_summary.lineno - 1] if frame_summary.lineno else "" + rawlines[frame_summary.lineno - 1] + if 1 <= frame_summary.lineno <= len(rawlines) + else "" ) else: lineno = frame_summary.lineno or 0