Quansight-Labs / pytest-run-parallel

A simple pytest plugin to run tests concurrently
MIT License
6 stars 3 forks source link

Auto detect usage of `pytest.warns` and similar context managers that depend on the warnings module #17

Closed andfoy closed 1 week ago

andfoy commented 1 week ago

As per a discussion over at SciPy https://github.com/scipy/scipy/pull/21496#issuecomment-2468909962, it would be much desirable to devise an introspection mechanism to detect usages of pytest.warns and similar constructs that depend on warning interception.

Given that the warnings module is not thread-safe, the current solution consists of marking such tests as single threaded, via pytest.mark.parallel_threads(1). By automating this process, libraries could accelerate their free-threading testing, as developers wouldn't have to devote time to find tests that capture warnings and then marking them as single-threaded manually.

This can be done via inspect.getsource and then introspection via ast

lysnikolaou commented 1 week ago

@andfoy Can I work on this or will you?

andfoy commented 1 week ago

I'm working on this at the moment