Skip to content

Commit 6d715e3

Browse files
committed
test: close session/otks only if local file.
Check for conn on db and if present do not close session or otks databases. Closing them on mysql caused a 2006 error even though the conn has different addresses.
1 parent 0573b15 commit 6d715e3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/session_common.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,20 @@ def setUp(self):
4747
self.otks = self.db.getOTKManager()
4848

4949
def tearDown(self):
50-
if hasattr(self, 'db'):
51-
self.db.close()
5250
if hasattr(self, 'sessions'):
53-
self.sessions.close()
51+
if not hasattr(self.sessions, 'conn'):
52+
# only do this for file based databases that do not
53+
# have a conn(ection). If they have a connection
54+
# mysql throws an error when closing self.db.
55+
self.sessions.close()
5456
if hasattr(self, 'otks'):
55-
self.otks.close()
57+
if not hasattr(self.otks, 'conn'):
58+
# only do this for file based databases that do not
59+
# have a conn(ection). If they have a connection
60+
# mysql throws an error when closing self.db.
61+
self.otks.close()
62+
if hasattr(self, 'db'):
63+
self.db.close()
5664
if os.path.exists(config.DATABASE):
5765
shutil.rmtree(config.DATABASE)
5866

0 commit comments

Comments
 (0)