From 5de13ea44aebee3493cd0cacaff071e465fb7576 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 17 Jul 2015 14:55:49 -0700 Subject: [PATCH] Use 'addCleanup' instead of 'tearDown' in engine(s) test Change-Id: I1d9b13b6f5cd48b7ac98f5c34ef9cb837f9ca7d1 --- taskflow/tests/unit/test_engines.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/taskflow/tests/unit/test_engines.py b/taskflow/tests/unit/test_engines.py index 0c3ac031..1a68aa7c 100644 --- a/taskflow/tests/unit/test_engines.py +++ b/taskflow/tests/unit/test_engines.py @@ -1106,14 +1106,15 @@ class WorkerBasedEngineTest(EngineTaskTest, self.worker_thread = tu.daemon_thread(self.worker.run) self.worker_thread.start() + # Ensure worker and thread is stopped when test is done; these are + # called in reverse order, so make sure we signal the stop before + # performing the join (because the reverse won't work). + self.addCleanup(self.worker_thread.join) + self.addCleanup(self.worker.stop) + # Make sure the worker is started before we can continue... self.worker.wait() - def tearDown(self): - self.worker.stop() - self.worker_thread.join() - super(WorkerBasedEngineTest, self).tearDown() - def _make_engine(self, flow, flow_detail=None, store=None): return taskflow.engines.load(flow, flow_detail=flow_detail,