From 2438fde6f2567ad34623d56a5aa96b4683bf89b3 Mon Sep 17 00:00:00 2001 From: Corey Wright Date: Mon, 15 Dec 2014 23:45:28 -0600 Subject: [PATCH] Fix timers not cleaned up on MySQL test skips If it's determined that a MySQL test should be skipped during setUp(), but after the parent setUp() has been called, having created and started a timer, then tearDown() is never called and the timer never cancelled, but left to expire during some future, unrelated test. Move call to parent setUp() to end of child setUp() to insure that the timer is only created and started after it's been determined that the test shouldn't be skipped (ie create_db()). --- tests/mysqldb_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mysqldb_test.py b/tests/mysqldb_test.py index 173bad3..e5a87d3 100644 --- a/tests/mysqldb_test.py +++ b/tests/mysqldb_test.py @@ -42,8 +42,6 @@ def mysql_requirement(_f): class TestMySQLdb(LimitedTestCase): def setUp(self): - super(TestMySQLdb, self).setUp() - self._auth = get_database_auth()['MySQLdb'] self.create_db() self.connection = None @@ -56,6 +54,8 @@ class TestMySQLdb(LimitedTestCase): self.connection.commit() cursor.close() + super(TestMySQLdb, self).setUp() + def tearDown(self): if self.connection: self.connection.close()