From d2703d81f086a9c3f7bb822046794668dde8ea6b Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Tue, 21 Apr 2015 11:00:04 +1000 Subject: [PATCH] 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 --- neutron/tests/base.py | 4 ++++ 1 file changed, 4 insertions(+) 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)) -- 2.45.2