[TIP] setup pytest fixtures in parallel

Wouter Overmeire lodagro at gmail.com
Thu Nov 23 23:02:45 PST 2017


Is there a way in pytest (or a plugin) to setup test fixtures in parallel?
Not running the tests in // but only setup the fixtures in //.

Suppose I have a number of tests and each have a different number of
The fixtures take long to setup, given they are independent of each other
and not cpu limited, setup could be done in //.

I prefer not to stuff all fixtures in one major fixture and control from
this one how to build.
Not all tests use the same fixtures, and fixtures come and go. Ideally I`m
looking for a way to add additional decorator (or arg on existing fixture
pytest decorator) on a fixture indicating it can be setup in //.

I`m familiar with the concept of scope on fixtures, but even for session
scoped fixtures I would like to setup them in //.

Probably not so trivial given fixtures can be hierarchical.

The hook pytest_fixture_setup looks the way to go, I`m wondering how to run
rest of the fixture setup chain in a thread and return the fixture when
done, This feels like breaking the api model behind hooks, given return
value of hook determines to stop the chain. Not modify rest of the call

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20171124/d1d8d385/attachment.htm>

More information about the testing-in-python mailing list