|
6 | 6 |
|
7 | 7 | from pytest_rerunfailures import HAS_PYTEST_HANDLECRASHITEM |
8 | 8 |
|
9 | | - |
10 | 9 | pytest_plugins = "pytester" |
11 | 10 |
|
12 | 11 | has_xdist = HAS_PYTEST_HANDLECRASHITEM |
@@ -717,31 +716,36 @@ def test_fail(): |
717 | 716 |
|
718 | 717 |
|
719 | 718 | @pytest.mark.parametrize( |
720 | | - "marker_rerun_except,cli_rerun_except,should_rerun", |
| 719 | + "marker_rerun_except,cli_rerun_except,raised_error,should_rerun", |
721 | 720 | [ |
722 | | - ("AssertionError", None, False), |
723 | | - ("AssertionError: ERR", None, False), |
724 | | - (["AssertionError"], None, False), |
725 | | - (["AssertionError: ABC"], None, True), |
726 | | - ("ValueError", None, True), |
727 | | - (["ValueError"], None, True), |
728 | | - (["OSError", "ValueError"], None, True), |
729 | | - (["OSError", "AssertionError"], None, False), |
| 721 | + ("AssertionError", None, "AssertionError", False), |
| 722 | + ("AssertionError: ERR", None, "AssertionError", False), |
| 723 | + (["AssertionError"], None, "AssertionError", False), |
| 724 | + (["AssertionError: ABC"], None, "AssertionError", True), |
| 725 | + ("ValueError", None, "AssertionError", True), |
| 726 | + (["ValueError"], None, "AssertionError", True), |
| 727 | + (["OSError", "ValueError"], None, "AssertionError", True), |
| 728 | + (["OSError", "AssertionError"], None, "AssertionError", False), |
730 | 729 | # CLI override behavior |
731 | | - ("AssertionError", "ValueError", False), |
732 | | - ("ValueError", "AssertionError", True), |
| 730 | + ("AssertionError", "ValueError", "AssertionError", False), |
| 731 | + ("ValueError", "AssertionError", "AssertionError", True), |
| 732 | + ("CustomFailure", None, "CustomFailure", False), |
| 733 | + ("CustomFailure", None, "AssertionError", True), |
733 | 734 | ], |
734 | 735 | ) |
735 | 736 | def test_rerun_except_flag_in_flaky_marker( |
736 | | - testdir, marker_rerun_except, cli_rerun_except, should_rerun |
| 737 | + testdir, marker_rerun_except, cli_rerun_except, raised_error, should_rerun |
737 | 738 | ): |
738 | 739 | testdir.makepyfile( |
739 | 740 | f""" |
740 | 741 | import pytest |
741 | 742 |
|
| 743 | + class CustomFailure(Exception): |
| 744 | + pass |
| 745 | +
|
742 | 746 | @pytest.mark.flaky(reruns=1, rerun_except={marker_rerun_except!r}) |
743 | 747 | def test_fail(): |
744 | | - raise AssertionError("ERR") |
| 748 | + raise {raised_error}("ERR") |
745 | 749 | """ |
746 | 750 | ) |
747 | 751 | args = [] |
|
0 commit comments