comparison tests/test_svnwrap.py @ 873:c58213aaf7c8

test_svnwrap: use test_util.rmtree() (or fix it)
author Patrick Mezard <patrick@mezard.eu>
date Fri, 20 Apr 2012 18:07:42 +0200
parents 312b37bc5e20
children f2de043ac924
comparison
equal deleted inserted replaced
872:a279b5838aaf 873:c58213aaf7c8
1 import test_util 1 import test_util
2 2
3 import imp 3 import imp
4 import os 4 import os
5 import subprocess 5 import subprocess
6 import shutil
7 import tempfile 6 import tempfile
8 import unittest 7 import unittest
9 8
10 from hgsubversion import svnwrap 9 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)
20 10
21 class TestBasicRepoLayout(unittest.TestCase): 11 class TestBasicRepoLayout(unittest.TestCase):
22 def setUp(self): 12 def setUp(self):
23 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 13 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
24 self.repo_path = '%s/testrepo' % self.tmpdir 14 self.repo_path = '%s/testrepo' % self.tmpdir
33 assert proc == 0 23 assert proc == 0
34 self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path)) 24 self.repo = svnwrap.SubversionRepo(test_util.fileurl(self.repo_path))
35 25
36 def tearDown(self): 26 def tearDown(self):
37 del self.repo 27 del self.repo
38 shutil.rmtree(self.tmpdir, onerror=lambda func, path, e: force_rm(path)) 28 test_util.rmtree(self.tmpdir)
39
40 29
41 def test_num_revs(self): 30 def test_num_revs(self):
42 revs = list(self.repo.revisions()) 31 revs = list(self.repo.revisions())
43 self.assertEqual(len(revs), 7) 32 self.assertEqual(len(revs), 7)
44 r = revs[1] 33 r = revs[1]