Mercurial > p > roundup > code
diff roundup/backends/sessions_dbm.py @ 7879:39c482e6a246
fix: fix code to make tests of session and otks databases pass on windows
The existing code had a few issues:
sessions_dbm.py:
detect dumbdbm when used on windows python and properly delete session/otks
databases so clear() works.
make sure the Session/Otks.cache_db_type() is called even when the database
is newly created.
test/session_common.py:
close session and otks database in teardown before deleting database
directory to prevent errors from deleting open files on windows.
test/test_sqlite.py:
close the session and otks databases opened by SessionTest.setUp(self)
so the salite session/otks database are closed before the new anydbm
sessions databases are opened for testing the sqlite main db and anydbm
as session/otks db. Again this causes deletion of database test directory
to fail on windows as you can't delete open files.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 18 Apr 2024 17:39:56 -0400 |
| parents | fe0091279f50 |
| children | 456edf872259 |
line wrap: on
line diff
--- a/roundup/backends/sessions_dbm.py Thu Apr 18 15:21:15 2024 -0400 +++ b/roundup/backends/sessions_dbm.py Thu Apr 18 17:39:56 2024 -0400 @@ -42,6 +42,9 @@ os.remove(path) elif os.path.exists(path+'.db'): # dbm appends .db os.remove(path+'.db') + elif os.path.exists(path+".dir"): # dumb dbm + os.remove(path+".dir") + os.remove(path+".dat") def cache_db_type(self, path): ''' determine which DB wrote the class file, and cache it as an @@ -142,7 +145,9 @@ # new database? let anydbm pick the best dbm if not db_type: - return anydbm.open(path, 'c') + db = anydbm.open(path, 'c') + self.cache_db_type(path) + return db # open the database with the correct module dbm = __import__(db_type)
