Mercurial > p > roundup > code
diff test/session_common.py @ 7890:9347c4a0ecd6
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 18 Apr 2024 23:09:45 -0400 |
| parents | 39c482e6a246 |
| children |
line wrap: on
line diff
--- a/test/session_common.py Thu Apr 18 22:28:58 2024 -0400 +++ b/test/session_common.py Thu Apr 18 23:09:45 2024 -0400 @@ -47,12 +47,20 @@ self.otks = self.db.getOTKManager() def tearDown(self): + if hasattr(self, 'sessions'): + if not hasattr(self.sessions, 'conn'): + # only do this for file based databases that do not + # have a conn(ection). If they have a connection + # mysql throws an error when closing self.db. + self.sessions.close() + if hasattr(self, 'otks'): + if not hasattr(self.otks, 'conn'): + # only do this for file based databases that do not + # have a conn(ection). If they have a connection + # mysql throws an error when closing self.db. + self.otks.close() if hasattr(self, 'db'): self.db.close() - if hasattr(self, 'sessions'): - self.sessions.close() - if hasattr(self, 'otks'): - self.otks.close() if os.path.exists(config.DATABASE): shutil.rmtree(config.DATABASE)
