(pytester: Pytester)
| 513 | |
| 514 | |
| 515 | def test_cache_error(pytester: Pytester) -> None: |
| 516 | pytester.makepyfile( |
| 517 | class="st">""" |
| 518 | def test_1(): pass |
| 519 | class="st">""" |
| 520 | ) |
| 521 | class="cm"># Run stepwise normally to generate the cache information. |
| 522 | result = pytester.runpytest(class="st">"--stepwise", class="st">"-v") |
| 523 | result.stdout.fnmatch_lines( |
| 524 | [ |
| 525 | class="st">"stepwise: no previously failed tests, not skipping.", |
| 526 | class="st">"*::test_1 *PASSED*", |
| 527 | class="st">"* 1 passed in *", |
| 528 | ] |
| 529 | ) |
| 530 | |
| 531 | class="cm"># Corrupt the cache. |
| 532 | cache_file = pytester.path / fclass="st">".pytest_cache/v/{STEPWISE_CACHE_DIR}" |
| 533 | assert cache_file.is_file() |
| 534 | cache_file.write_text(json.dumps({class="st">"invalid": True}), encoding=class="st">"UTF-8") |
| 535 | |
| 536 | class="cm"># Check we run as if the cache did not exist, but also show an error message. |
| 537 | result = pytester.runpytest(class="st">"--stepwise", class="st">"-v") |
| 538 | result.stdout.fnmatch_lines( |
| 539 | [ |
| 540 | class="st">"stepwise: error reading cache, discarding (KeyError: *", |
| 541 | class="st">"stepwise: no previously failed tests, not skipping.", |
| 542 | class="st">"*::test_1 *PASSED*", |
| 543 | class="st">"* 1 passed in *", |
| 544 | ] |
| 545 | ) |
nothing calls this directly
no test coverage detected