(pytester: Pytester)
| 5 | |
| 6 | @pytest.fixture |
| 7 | def stepwise_pytester(pytester: Pytester) -> Pytester: |
| 8 | # Rather than having to modify our testfile between tests, we introduce |
| 9 | # a flag for whether or not the second test should fail. |
| 10 | pytester.makeconftest( |
| 11 | """ |
| 12 | def pytest_addoption(parser): |
| 13 | group = parser.getgroup('general') |
| 14 | group.addoption('--fail', action='store_true', dest='fail') |
| 15 | group.addoption('--fail-last', action='store_true', dest='fail_last') |
| 16 | """ |
| 17 | ) |
| 18 | |
| 19 | # Create a simple test suite. |
| 20 | pytester.makepyfile( |
| 21 | test_a=""" |
| 22 | def test_success_before_fail(): |
| 23 | assert 1 |
| 24 | |
| 25 | def test_fail_on_flag(request): |
| 26 | assert not request.config.getvalue('fail') |
| 27 | |
| 28 | def test_success_after_fail(): |
| 29 | assert 1 |
| 30 | |
| 31 | def test_fail_last_on_flag(request): |
| 32 | assert not request.config.getvalue('fail_last') |
| 33 | |
| 34 | def test_success_after_last_fail(): |
| 35 | assert 1 |
| 36 | """ |
| 37 | ) |
| 38 | |
| 39 | pytester.makepyfile( |
| 40 | test_b=""" |
| 41 | def test_success(): |
| 42 | assert 1 |
| 43 | """ |
| 44 | ) |
| 45 | |
| 46 | # customize cache directory so we don't use the tox's cache directory, which makes tests in this module flaky |
| 47 | pytester.makeini( |
| 48 | """ |
| 49 | [pytest] |
| 50 | cache_dir = .cache |
| 51 | """ |
| 52 | ) |
| 53 | |
| 54 | return pytester |
| 55 | |
| 56 | |
| 57 | @pytest.fixture |
nothing calls this directly
no test coverage detected