changeset 481:e5a9c824ffbf

Make tearDown() be able to delete read-only files to avoid an exception when removing 'testrepo/db/format'
author Risto Kankkunen <risto.kankkunen@iki.fi>
date Wed, 29 Jul 2009 18:03:02 +0300
parents 7fa100ae1a11
children a42fb4f1716a
files tests/test_svnwrap.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_svnwrap.py
+++ b/tests/test_svnwrap.py
@@ -9,6 +9,15 @@ import test_util
 
 from hgsubversion import svnwrap
 
+import os
+import stat
+def force_rm(path):
+    os.chmod(
+        path,
+        os.stat(path).st_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
+    )
+    os.remove(path)
+
 class TestBasicRepoLayout(unittest.TestCase):
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp('svnwrap_test')
@@ -25,7 +34,7 @@ class TestBasicRepoLayout(unittest.TestC
         self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path))
 
     def tearDown(self):
-        shutil.rmtree(self.tmpdir)
+        shutil.rmtree(self.tmpdir, onerror=lambda func, path, e: force_rm(path))
 
 
     def test_num_revs(self):