changeset 689:35a1e93b6f78

tests: move _add_svn_rev to test_util for reuse
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Wed, 08 Sep 2010 09:57:06 +0200
parents 073132fc27f1
children 4b55fb6d6847
files tests/test_pull.py tests/test_util.py
diffstat 2 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_pull.py
+++ b/tests/test_pull.py
@@ -9,35 +9,12 @@ from mercurial import commands
 class TestPull(test_util.TestBase):
     def setUp(self):
         super(TestPull, self).setUp()
-        self.svn_wc = None
 
     def _load_fixture_and_fetch(self, fixture_name):
         return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
                                                 self.wc_path, stupid=False,
                                                 noupdate=False)
 
-    def _add_svn_rev(self, changes):
-        # changes is a dict of filename -> contents
-        if self.svn_wc is None:
-            self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc')
-            subprocess.call([
-                'svn', 'co', '-q', test_util.fileurl(self.repo_path), 
-                self.svn_wc
-            ],
-            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
-        for filename, contents in changes.iteritems():
-            # filenames are / separated
-            filename = filename.replace('/', os.path.sep)
-            filename = os.path.join(self.svn_wc, filename)
-            open(filename, 'w').write(contents)
-            # may be redundant
-            subprocess.call(['svn', 'add', '-q', filename],
-                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        subprocess.call([
-            'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes'],
-            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
     def test_nochanges(self):
         self._load_fixture_and_fetch('single_rev.svndump')
         state = self.repo.parents()
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -184,6 +184,7 @@ class TestBase(unittest.TestCase):
 
         self.repo_path = '%s/testrepo' % self.tmpdir
         self.wc_path = '%s/testrepo_wc' % self.tmpdir
+        self.svn_wc = None
 
         # Previously, we had a MockUI class that wrapped ui, and giving access
         # to the stream. The ui.pushbuffer() and ui.popbuffer() can be used
@@ -232,6 +233,28 @@ class TestBase(unittest.TestCase):
                                       stupid=stupid, layout=layout,
                                       startrev=startrev)
 
+    def _add_svn_rev(self, changes):
+        '''changes is a dict of filename -> contents'''
+        if self.svn_wc is None:
+            self.svn_wc = os.path.join(self.tmpdir, 'testsvn_wc')
+            subprocess.call([
+                'svn', 'co', '-q', fileurl(self.repo_path),
+                self.svn_wc
+            ],
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
+        for filename, contents in changes.iteritems():
+            # filenames are / separated
+            filename = filename.replace('/', os.path.sep)
+            filename = os.path.join(self.svn_wc, filename)
+            open(filename, 'w').write(contents)
+            # may be redundant
+            subprocess.call(['svn', 'add', '-q', filename],
+                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        subprocess.call([
+            'svn', 'commit', '-q', self.svn_wc, '-m', 'test changes'],
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+
     # define this as a property so that it reloads anytime we need it
     @property
     def repo(self):