Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/362.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``INTERNALERROR`` when ``only_rerun`` or ``rerun_except`` is given a bare exception class instead of a list.
4 changes: 3 additions & 1 deletion src/pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ def _get_rerun_filter_regex(item, regex_name):

if rerun_marker is not None and regex_name in rerun_marker.kwargs:
regex = rerun_marker.kwargs[regex_name]
if isinstance(regex, str):
if isinstance(regex, str) or (
isinstance(regex, type) and issubclass(regex, BaseException)
):
regex = [regex]
else:
regex = getattr(item.session.config.option, regex_name)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,10 @@ def test_fail():
("only_rerun=[ValueError]", False),
("rerun_except=[AssertionError]", False),
("rerun_except=[ValueError]", True),
("only_rerun=AssertionError", True),
("only_rerun=ValueError", False),
("rerun_except=AssertionError", False),
("rerun_except=ValueError", True),
],
)
def test_rerun_filter_accepts_exception_classes(testdir, filter_kwarg, should_rerun):
Expand Down