Skip to content

Commit 91f29c9

Browse files
committed
Handle test failures without a line number
This can happen with Pytest plugins such as pytest-mypy which emits test failures (type checking errors) differently than Pytest normally does for regular unit tests. The errors will instead be reported against the file as a whole. Fixes #46.
1 parent 6cb5788 commit 91f29c9

File tree

1 file changed

+3
-2
lines changed
  • pytest_github_actions_annotate_failures

1 file changed

+3
-2
lines changed

pytest_github_actions_annotate_failures/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def pytest_runtest_makereport(item, call):
4949
if not rel_path.startswith(".."):
5050
filesystempath = rel_path
5151

52-
# 0-index to 1-index
53-
lineno += 1
52+
if lineno is not None:
53+
# 0-index to 1-index
54+
lineno += 1
5455

5556
# get the name of the current failed test, with parametrize info
5657
longrepr = report.head_line or item.name

0 commit comments

Comments
 (0)