We have been using nosetest for running and collecting our unittests (which are all written as python unittests which we like). Things we like about nose:
- uses standard python unit tests (we like the structure this imposes).
- supports reporting coverage and test output in xml (for jenkins).
What we are missing is a good way to run tests in isolated processes while maintaining good error repoorting (we are testing C++ libraries through python so segfaults should not be catastrophic). nosepipe seems to be no longer maintained and we have some problems with it.
We are trying to figure out whether we should - fix/use nosepipe - switch to nose2 and write nosepipe2. - use pytest or some other testing framework.
We would prefer to use an approach with a good community. It seems our problem (C++ plugins requiring good isolation) might be a common problem but googling I have not found solutions that are maintained. Advice from more experienced heads appreciated.
pytest has the xdist plugin which provides the
--boxed
option to run each test in a controlled subprocess. Here is a basic example::If you run this with::
You'll see that a couple of tests are reported as crashing, indicated by lower-case
f
and the respective failure summary. You can also use the xdist-provided parallelization feature to speed up your testing::In principle, just distributing to parallel subprocesses may often suffice and avoids the overhead of starting a boxed process for each test. This currently only works if you only have less crashing tests than the
-n
number of processes because a dying testing process is not restarted. This limitation could probably be removed without too much effort. Meanwhile you will have to use the safe boxing option.