|
| 1 | +def test_skip(testdir): |
| 2 | + string = """ |
| 3 | + Lorem ipsum |
| 4 | +
|
| 5 | + <!--pytest-codeblocks:skip--> |
| 6 | +
|
| 7 | + ```python |
| 8 | + print(1 + 3) |
| 9 | + ``` |
| 10 | + """ |
| 11 | + testdir.makefile(".md", string) |
| 12 | + result = testdir.runpytest("--codeblocks") |
| 13 | + result.assert_outcomes(skipped=1) |
| 14 | + |
| 15 | + |
| 16 | +def test_skip_expected_output(testdir): |
| 17 | + string = """ |
| 18 | + Lorem ipsum |
| 19 | +
|
| 20 | + <!--pytest-codeblocks:skip--> |
| 21 | +
|
| 22 | + ```python |
| 23 | + print(1 + 3) |
| 24 | + ``` |
| 25 | +
|
| 26 | + <!--pytest-codeblocks:expected-output--> |
| 27 | +
|
| 28 | + ``` |
| 29 | + 25abc |
| 30 | + ``` |
| 31 | +
|
| 32 | + """ |
| 33 | + testdir.makefile(".md", string) |
| 34 | + result = testdir.runpytest("--codeblocks") |
| 35 | + result.assert_outcomes(skipped=1) |
| 36 | + |
| 37 | + |
| 38 | +def test_skipif(testdir): |
| 39 | + string = """ |
| 40 | + Lorem ipsum |
| 41 | +
|
| 42 | + <!--pytest-codeblocks:skipif(1 < 3)--> |
| 43 | +
|
| 44 | + ```python |
| 45 | + print(1 + 3) |
| 46 | + ``` |
| 47 | + """ |
| 48 | + testdir.makefile(".md", string) |
| 49 | + result = testdir.runpytest("--codeblocks") |
| 50 | + result.assert_outcomes(skipped=1) |
| 51 | + |
| 52 | + string = """ |
| 53 | + Lorem ipsum |
| 54 | +
|
| 55 | + <!--pytest-codeblocks:skipif(1 > 3)--> |
| 56 | +
|
| 57 | + ```python |
| 58 | + print(1 + 3) |
| 59 | + ``` |
| 60 | + """ |
| 61 | + testdir.makefile(".md", string) |
| 62 | + result = testdir.runpytest("--codeblocks") |
| 63 | + result.assert_outcomes(passed=1) |
| 64 | + |
| 65 | + |
| 66 | +def test_skipif_expected_output(testdir): |
| 67 | + string = """ |
| 68 | + Lorem ipsum |
| 69 | +
|
| 70 | + <!--pytest-codeblocks:skipif(1 < 3)--> |
| 71 | +
|
| 72 | + ```python |
| 73 | + print(1 + 3) |
| 74 | + ``` |
| 75 | +
|
| 76 | + <!--pytest-codeblocks:expected-output--> |
| 77 | +
|
| 78 | + ``` |
| 79 | + 25abc |
| 80 | + ``` |
| 81 | +
|
| 82 | + """ |
| 83 | + testdir.makefile(".md", string) |
| 84 | + result = testdir.runpytest("--codeblocks") |
| 85 | + result.assert_outcomes(skipped=1) |
| 86 | + |
| 87 | + string = """ |
| 88 | + Lorem ipsum |
| 89 | +
|
| 90 | + <!--pytest-codeblocks:skipif(1 > 3)--> |
| 91 | +
|
| 92 | + ```python |
| 93 | + print(1 + 3) |
| 94 | + ``` |
| 95 | +
|
| 96 | + <!--pytest-codeblocks:expected-output--> |
| 97 | +
|
| 98 | + ``` |
| 99 | + 4 |
| 100 | + ``` |
| 101 | +
|
| 102 | + """ |
| 103 | + testdir.makefile(".md", string) |
| 104 | + result = testdir.runpytest("--codeblocks") |
| 105 | + result.assert_outcomes(passed=1) |
0 commit comments