Open webknjaz opened 4 years ago
For me, the easiest workaround is just to use a different decorator:
import sys
import pytest
if sys.platform == "win32":
forked = pytest.mark.skip(reason="Windows doesn't fork")
else:
forked = pytest.mark.forked
@forked
def test_thing_in_fork():
...
The first branch could also be forked = lambda f: f
to fall back to non-forking, as in option 3 above.
~You can write this, place it anywhere in conftest and use the marker like normal:~
@pytest.fixture(autouse=True)
def skip_forked_tests_on_windows(request):
if request.node.get_closest_marker("forked") and sys.platform == "win32":
pytest.skip("Windows doesn't work")
EDIT: Ah the fixture is only executed in the forked process, that's a bummer
Currently, if the test is marked with
forked
, this plugin tries to run it in a forked subprocess regardless of the current env. Also, adding a conditional skip marker does not help and manifests itself as https://github.com/pytest-dev/pytest/issues/7327.The following snippet still runs on Windows:
The workaround that I currently use is:
This could be addressed in a few ways:
I think I like 1+2 most.