From 8a2282402eca17ca97f2a2e29523a1756d0f0e1c Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Sep 18 2018 08:38:05 +0000 Subject: Prevent leaking of test state by aborting Signed-off-by: Patrick Uiterwijk --- diff --git a/tests/__init__.py b/tests/__init__.py index f0e9553..d24842c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -341,10 +341,19 @@ class SimplePagureTest(unittest.TestCase): perfrepo.REQUESTS = [] def setUp(self): + if self.path: + # This prevents test state leakage. + # This should be None if the previous runs' tearDown didn't finish, + # leaving behind a self.path. + # If we continue in this case, not only did the previous worker and + # redis instances not exit, we also might accidentally use the + # old database connection. + # @pingou, don't delete this again... :) + raise Exception('Previous test failed!') + self.perfReset() - if not self.path: - self.path = tempfile.mkdtemp(prefix='pagure-tests-path-') + self.path = tempfile.mkdtemp(prefix='pagure-tests-path-') LOG.debug('Testdir: %s', self.path) for folder in ['repos', 'forks', 'releases', 'remotes', 'attachments']: