Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 7889:a5d39e5a5cdc | 7890:9347c4a0ecd6 |
|---|---|
| 45 self.db = self.module.Database(config, 'admin') | 45 self.db = self.module.Database(config, 'admin') |
| 46 self.sessions = self.db.getSessionManager() | 46 self.sessions = self.db.getSessionManager() |
| 47 self.otks = self.db.getOTKManager() | 47 self.otks = self.db.getOTKManager() |
| 48 | 48 |
| 49 def tearDown(self): | 49 def tearDown(self): |
| 50 if hasattr(self, 'sessions'): | |
| 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() | |
| 56 if hasattr(self, 'otks'): | |
| 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() | |
| 50 if hasattr(self, 'db'): | 62 if hasattr(self, 'db'): |
| 51 self.db.close() | 63 self.db.close() |
| 52 if hasattr(self, 'sessions'): | |
| 53 self.sessions.close() | |
| 54 if hasattr(self, 'otks'): | |
| 55 self.otks.close() | |
| 56 if os.path.exists(config.DATABASE): | 64 if os.path.exists(config.DATABASE): |
| 57 shutil.rmtree(config.DATABASE) | 65 shutil.rmtree(config.DATABASE) |
| 58 | 66 |
| 59 def testList(self): | 67 def testList(self): |
| 60 '''Under dbm/memory sessions store, keys are returned as | 68 '''Under dbm/memory sessions store, keys are returned as |
