pytest-dev / pytest-forked

extracted --boxed from pytest-xdist to ensure backward compat
MIT License
62 stars 21 forks source link

Alternative to fork in Windows #56

Closed Astlaan closed 2 years ago

Astlaan commented 2 years ago

Hi.

I understand that the forking functionality is not supported in windows. Is there however any other way package capable of running the different test functions in different processes?

My code is something like:

# test_scripts.py

scripts = [ ... ]   #list of filepaths

@pytest.mark.parametrize('script', scripts)
def test_script_execution(script):
    runpy.run_path(script)

The scripts don't need any variables or state from this process (so I don't exactly need to fork), but they do need to be run in different processes, since they use packages containing global variables.

Is there any way to use pytest for this in windows?

RonnyPfannschmidt commented 2 years ago

At that point why not just run the actual subprocess?

Astlaan commented 2 years ago

Turns out that pytest-xdist -n parameter works well for my needs.

Thanks