DietTestCase catches SystemExit while running tests, interprets it as a
test failure, and then carry on with the next test (without exiting).
This greatly upsets forked child python processes, which may call exit()
legitimately, and expect that to result in process exit.
This change re-raises the SystemExit if the current process ID is not
the original pid.
Change-Id: Ia39a350b562b2856b5588cd73826afb3d072554f
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
self.addOnException(self.check_for_systemexit)
+ self.orig_pid = os.getpid()
def check_for_systemexit(self, exc_info):
if isinstance(exc_info[1], SystemExit):
+ if os.getpid() != self.orig_pid:
+ # Subprocess - let it just exit
+ raise
self.fail("A SystemExit was raised during the test. %s"
% traceback.format_exception(*exc_info))