[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. stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 13 Apr 2011 11:34:53 +0200
branchstable
changeset 7217 4b860903d8c7
parent 7215 2da7f3ec4e6f
child 7218 78622865b6c1
child 7219 d961184f9a86
[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.
devtools/__init__.py
--- 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):