tonybaloney / pytest-freethreaded

MIT License
31 stars 3 forks source link

Introduce `@pytest.mark.threadunsafe` to disable thread-based parallelism for specific tests #19

Open ogrisel opened 1 month ago

ogrisel commented 1 month ago

Some tests can be fundamentally not amenable for parallel execution. For instance:

It would be nice to have a standard way to mark such tests as unexpected to pass in a thread-based parallel execution setting, and have plugins such as pytest-freethreaded or pytest-run-parallel respect that marker to run them sequentially instead.

This proposal stems from this discussion on the scikit-learn issue tracker with pytest-run-parallel developer @andfoy.

ogrisel commented 1 month ago

For convenience, the runner itself could alternatively detect known fixture usage and code pattern (usage of pytest.warns) that are fundamentally not thread-safe and automatically run those tests sequentially.