comparison tests/test_svnwrap.py @ 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
comparison
equal deleted inserted replaced
480:7fa100ae1a11 481:e5a9c824ffbf
6 import unittest 6 import unittest
7 7
8 import test_util 8 import test_util
9 9
10 from hgsubversion import svnwrap 10 from hgsubversion import svnwrap
11
12 import os
13 import stat
14 def force_rm(path):
15 os.chmod(
16 path,
17 os.stat(path).st_mode | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
18 )
19 os.remove(path)
11 20
12 class TestBasicRepoLayout(unittest.TestCase): 21 class TestBasicRepoLayout(unittest.TestCase):
13 def setUp(self): 22 def setUp(self):
14 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 23 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
15 self.repo_path = '%s/testrepo' % self.tmpdir 24 self.repo_path = '%s/testrepo' % self.tmpdir
23 stderr=subprocess.STDOUT) 32 stderr=subprocess.STDOUT)
24 assert proc == 0 33 assert proc == 0
25 self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path)) 34 self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path))
26 35
27 def tearDown(self): 36 def tearDown(self):
28 shutil.rmtree(self.tmpdir) 37 shutil.rmtree(self.tmpdir, onerror=lambda func, path, e: force_rm(path))
29 38
30 39
31 def test_num_revs(self): 40 def test_num_revs(self):
32 revs = list(self.repo.revisions()) 41 revs = list(self.repo.revisions())
33 self.assertEqual(len(revs), 7) 42 self.assertEqual(len(revs), 7)