In my scenario, I have one test that writes a file, and one (but potentially many more) tests that would want to read that file. I cannot simply extract writing that file to a function/fixture, because it involves some other fixtures that inside are starting some other binary and it that binary that writes that file. So I have a fixture, that checks if the file is already there.
What I tried so far:
- flaky and pytest-rerunfailures plugins - not suitable, as they both rerun the test instantly on failure (when the file still isn't there), and I want to append it at end of test queue.
- manually modifying the test queue, like this:
...
request.session.items.append(request.node)
pytest.xfail("file not present yet")
this kind of works, but only when I run on single runner (without xdist, or turning it on, by passing -n0
cli arg,
in my test report I see something like this:
test_load_file_before_save xfail
test_save_file PASSED
test_load_file PASSED
test_load_file_before_save PASSED
when run with xdist, the xfailed test does not get repeated. Anyone know how to proceed? Some way to force xdist refresh the test list?