[testlib] fix bug in backup file name generation: it may erroneously replace '-' by '_' in database **parent directories**. This should fix random error when test are run under apycot.
--- a/devtools/__init__.py Wed Apr 13 09:58:19 2011 +0200
+++ b/devtools/__init__.py Wed Apr 13 11:34:53 2011 +0200
@@ -299,9 +299,12 @@
def absolute_backup_file(self, db_id, suffix):
"""Path for config backup of a given database id"""
- dbname = self.dbname.replace('-', '_')
+ # in case db name is an absolute path, we don't want to replace anything
+ # in parent directories
+ directory, basename = split(self.dbname)
+ dbname = basename.replace('-', '_')
assert '.' not in db_id
- filename = '%s-%s.%s' % (dbname, db_id, suffix)
+ filename = join(directory, '%s-%s.%s' % (dbname, db_id, suffix))
return join(self._ensure_test_backup_db_dir(), filename)
def db_cache_key(self, db_id, dbname=None):