|
| 1 | +def test_order_after_ff(test_path): |
| 2 | + test_path.makepyfile( |
| 3 | + test_failing=( |
| 4 | + """ |
| 5 | + import pytest |
| 6 | +
|
| 7 | + @pytest.mark.order("second") |
| 8 | + def test_me_second(): |
| 9 | + assert True |
| 10 | +
|
| 11 | + def test_that_fails(): |
| 12 | + assert False |
| 13 | +
|
| 14 | + def test_after_failed(): |
| 15 | + assert True |
| 16 | +
|
| 17 | + @pytest.mark.order("first") |
| 18 | + def test_me_first(): |
| 19 | + assert True |
| 20 | + """ |
| 21 | + ) |
| 22 | + ) |
| 23 | + result = test_path.runpytest("-v") |
| 24 | + result.assert_outcomes(passed=3, failed=1) |
| 25 | + result.stdout.fnmatch_lines( |
| 26 | + [ |
| 27 | + "test_failing.py::test_me_first PASSED", |
| 28 | + "test_failing.py::test_me_second PASSED", |
| 29 | + "test_failing.py::test_that_fails FAILED", |
| 30 | + "test_failing.py::test_after_failed PASSED", |
| 31 | + ] |
| 32 | + ) |
| 33 | + |
| 34 | + result = test_path.runpytest("-v", "--ff") |
| 35 | + result.assert_outcomes(passed=3, failed=1) |
| 36 | + result.stdout.fnmatch_lines( |
| 37 | + [ |
| 38 | + "test_failing.py::test_that_fails FAILED", |
| 39 | + "test_failing.py::test_me_first PASSED", |
| 40 | + "test_failing.py::test_me_second PASSED", |
| 41 | + "test_failing.py::test_after_failed PASSED", |
| 42 | + ] |
| 43 | + ) |
| 44 | + |
| 45 | + result = test_path.runpytest("-v", "--ff", "--order-after-ff") |
| 46 | + result.assert_outcomes(passed=3, failed=1) |
| 47 | + result.stdout.fnmatch_lines( |
| 48 | + [ |
| 49 | + "test_failing.py::test_me_first PASSED", |
| 50 | + "test_failing.py::test_me_second PASSED", |
| 51 | + "test_failing.py::test_that_fails FAILED", |
| 52 | + "test_failing.py::test_after_failed PASSED", |
| 53 | + ] |
| 54 | + ) |
| 55 | + |
| 56 | + |
| 57 | +def test_indulgent_ordering(test_path): |
| 58 | + test_path.makepyfile( |
| 59 | + test_failing=( |
| 60 | + """ |
| 61 | + import pytest |
| 62 | +
|
| 63 | + @pytest.mark.order("second") |
| 64 | + def test_me_second(): |
| 65 | + assert True |
| 66 | +
|
| 67 | + def test_me_third(): |
| 68 | + assert True |
| 69 | +
|
| 70 | + @pytest.mark.order("first") |
| 71 | + def test_me_first(): |
| 72 | + assert True |
| 73 | +
|
| 74 | + def test_me_fourth(): |
| 75 | + assert True |
| 76 | + """ |
| 77 | + ) |
| 78 | + ) |
| 79 | + result = test_path.runpytest("-v") |
| 80 | + result.assert_outcomes(passed=4) |
| 81 | + result.stdout.fnmatch_lines( |
| 82 | + [ |
| 83 | + "test_failing.py::test_me_first PASSED", |
| 84 | + "test_failing.py::test_me_second PASSED", |
| 85 | + "test_failing.py::test_me_third PASSED", |
| 86 | + "test_failing.py::test_me_fourth PASSED", |
| 87 | + ] |
| 88 | + ) |
| 89 | + |
| 90 | + result = test_path.runpytest("-v", "-p", "tests.plugin_reverse") |
| 91 | + result.assert_outcomes(passed=4) |
| 92 | + result.stdout.fnmatch_lines( |
| 93 | + [ |
| 94 | + "test_failing.py::test_me_first PASSED", |
| 95 | + "test_failing.py::test_me_second PASSED", |
| 96 | + "test_failing.py::test_me_fourth PASSED", |
| 97 | + "test_failing.py::test_me_third PASSED", |
| 98 | + ] |
| 99 | + ) |
| 100 | + |
| 101 | + result = test_path.runpytest( |
| 102 | + "-v", |
| 103 | + "-p", |
| 104 | + "tests.plugin_reverse", |
| 105 | + "--indulgent-ordering", |
| 106 | + ) |
| 107 | + result.assert_outcomes(passed=4) |
| 108 | + result.stdout.fnmatch_lines( |
| 109 | + [ |
| 110 | + "test_failing.py::test_me_fourth PASSED", |
| 111 | + "test_failing.py::test_me_third PASSED", |
| 112 | + "test_failing.py::test_me_second PASSED", |
| 113 | + "test_failing.py::test_me_first PASSED", |
| 114 | + ] |
| 115 | + ) |
0 commit comments