diff tests/test_util.py @ 865:04729f3a3d17

test_util: merge load_fixture_and_fetch() into TestBase method The middle-term goal is to make TestBase repo_path and wc_path private, so they can be changed for every load call. This is not required to use nosetests multiprocess facility as the fixtures create temporary directories but it makes things much clearer and avoid weird cases where a repository was loaded several times at the same location in a single test (cf test_startrev). That way we will be more confident the tests can be parallelized. The long term goal is to make hgsubversion compatible with nosetests --processes option.
author Patrick Mezard <patrick@mezard.eu>
date Thu, 19 Apr 2012 18:29:25 +0200
parents e9af7eba88db
children 20e73b5ab6f7
line wrap: on
line diff
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -177,31 +177,6 @@ def dispatch(cmd):
     except AttributeError, e:
         dispatchmod.dispatch(cmd)
 
-def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False,
-                           subdir='', noupdate=True, layout='auto',
-                           startrev=0, externals=None):
-    load_svndump_fixture(repo_path, fixture_name)
-    if subdir:
-        repo_path += '/' + subdir
-
-    cmd = [
-        'clone',
-        '--layout=%s' % layout,
-        '--startrev=%s' % startrev,
-        fileurl(repo_path),
-        wc_path,
-    ]
-    if stupid:
-        cmd.append('--stupid')
-    if noupdate:
-        cmd.append('--noupdate')
-    if externals:
-        cmd[:0] = ['--config', 'hgsubversion.externals=%s' % externals]
-
-    dispatch(cmd)
-
-    return hg.repository(testui(), wc_path)
-
 def rmtree(path):
     # Read-only files cannot be removed under Windows
     for root, dirs, files in os.walk(path):
@@ -292,16 +267,35 @@ class TestBase(unittest.TestCase):
         return testui(stupid, layout)
 
     def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False,
-                                layout='auto', startrev=0, externals=None):
+                                layout='auto', startrev=0, externals=None,
+                                noupdate=True):
         if layout == 'single':
             if subdir is None:
                 subdir = 'trunk'
         elif subdir is None:
             subdir = ''
-        return load_fixture_and_fetch(fixture_name, self.repo_path,
-                                      self.wc_path, subdir=subdir,
-                                      stupid=stupid, layout=layout,
-                                      startrev=startrev, externals=externals)
+        load_svndump_fixture(self.repo_path, fixture_name)
+        projectpath = self.repo_path
+        if subdir:
+            projectpath += '/' + subdir
+
+        cmd = [
+            'clone',
+            '--layout=%s' % layout,
+            '--startrev=%s' % startrev,
+            fileurl(projectpath),
+            self.wc_path,
+            ]
+        if stupid:
+            cmd.append('--stupid')
+        if noupdate:
+            cmd.append('--noupdate')
+        if externals:
+            cmd[:0] = ['--config', 'hgsubversion.externals=%s' % externals]
+
+        dispatch(cmd)
+
+        return hg.repository(testui(), self.wc_path)
 
     def _add_svn_rev(self, changes):
         '''changes is a dict of filename -> contents'''