From: Angus Lees Date: Tue, 21 Apr 2015 01:00:04 +0000 (+1000) Subject: SystemExit is ok for child processes X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d2703d81f086a9c3f7bb822046794668dde8ea6b;p=openstack-build%2Fneutron-build.git SystemExit is ok for child processes 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 --- diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 0e1c8a079..87f820cc4 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -159,9 +159,13 @@ class DietTestCase(testtools.TestCase): 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))