From 59b3d2af8dbf6f730221f686a645ae4a8578dbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 2 Apr 2020 21:15:39 +0200 Subject: [PATCH] tests/fprintd-utils: Call addCleanup actions in reverse order unittest addCleanup calls are called in reverse order, so we need to reverse the order of the calls as well, otherwise we won't correctly terminate the subprocess children --- tests/fprintd.py | 2 +- tests/test_fprintd_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/fprintd.py b/tests/fprintd.py index 0bd9ac3..7351980 100755 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -1123,8 +1123,8 @@ class FPrintdUtilsTest(FPrintdVirtualDeviceBaseTest): env=env, stdout=None, stderr=subprocess.STDOUT) - self.addCleanup(self.utils_proc[name].terminate) self.addCleanup(self.utils_proc[name].wait) + self.addCleanup(self.utils_proc[name].terminate) return self.utils_proc[name] def test_vanished_client_operation_is_cancelled(self): diff --git a/tests/test_fprintd_utils.py b/tests/test_fprintd_utils.py index 4cc1841..e609b83 100755 --- a/tests/test_fprintd_utils.py +++ b/tests/test_fprintd_utils.py @@ -93,9 +93,9 @@ class TestFprintdUtilsBase(dbusmock.DBusTestCase): flags = fcntl.fcntl(process.stdout, fcntl.F_GETFL) fcntl.fcntl(process.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) - self.addCleanup(lambda: print(process.stdout.read())) - self.addCleanup(process.terminate) self.addCleanup(process.wait) + self.addCleanup(process.terminate) + self.addCleanup(lambda: print(process.stdout.read())) if sleep: time.sleep(self.sleep_time)