I'm building an application which starts processes using subprocess.Popen()
. Those processes may, depending on what they do, start processes of their own. As part of by test suite, I want to thoroughly test that functionality, but I fear that eventual bugs in my code may lead to numerous processes (across the many test cases) staying alive, which I would have to clean up manually.
Is there some functionality in py.test, or a plugin, which could solve this problem and clean up all processes started during the execution of a test case? Bonus points if processes, which had to be cleaned up, are reported and/or counted towards a test case failure.