Ensure stop of disk accountant on assertion
If one of the assertions hit the disk accountant thread is not
stopped. Due to this all further tests in the same batch are broken
during shutdown.
Change-Id: I9534c206bbb2e20a2bc44eba5317d136ed422957
diff --git a/tests/unit/test_disk_accountant.py b/tests/unit/test_disk_accountant.py
index 22c8f34..40b3b72 100644
--- a/tests/unit/test_disk_accountant.py
+++ b/tests/unit/test_disk_accountant.py
@@ -51,8 +51,10 @@
if jobdir in executor_server.stopped_jobs:
break
time.sleep(0.1)
- self.assertEqual(set([jobdir]), executor_server.stopped_jobs)
- da.stop()
+ try:
+ self.assertEqual(set([jobdir]), executor_server.stopped_jobs)
+ finally:
+ da.stop()
self.assertFalse(da.thread.is_alive())
def test_cache_hard_links(self):
@@ -83,7 +85,9 @@
if jobdir in executor_server.used:
break
time.sleep(0.1)
- self.assertEqual(set(), executor_server.stopped_jobs)
- self.assertIn(jobdir, executor_server.used)
- self.assertEqual(1, executor_server.used[jobdir])
- da.stop()
+ try:
+ self.assertEqual(set(), executor_server.stopped_jobs)
+ self.assertIn(jobdir, executor_server.used)
+ self.assertEqual(1, executor_server.used[jobdir])
+ finally:
+ da.stop()