# HG changeset patch # User Patrick Mezard # Date 1334852968 -7200 # Node ID 50c13e01c7e3174df896a8ed51e09c1d807acf1d # Parent 20e73b5ab6f7eedb648d1c2da12c12b8bfcfa215 test_util: add a load_and_fetch() returning the repo_path diff --git a/tests/comprehensive/test_stupid_pull.py b/tests/comprehensive/test_stupid_pull.py --- a/tests/comprehensive/test_stupid_pull.py +++ b/tests/comprehensive/test_stupid_pull.py @@ -19,11 +19,12 @@ from hgsubversion import wrappers def _do_case(self, name, layout): subdir = test_util.subdir.get(name, '') - self._load_fixture_and_fetch(name, subdir=subdir, stupid=False, layout=layout) + repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=False, + layout=layout) assert len(self.repo) > 0, 'Repo had no changes, maybe you need to add a subdir entry in test_util?' wc2_path = self.wc_path + '_stupid' u = ui.ui() - checkout_path = self.repo_path + checkout_path = repo_path if subdir: checkout_path += '/' + subdir u.setconfig('hgsubversion', 'stupid', '1') diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py --- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -67,7 +67,8 @@ class MapTests(test_util.TestBase): self.test_author_map_closing_author(True) def test_author_map_no_author(self, stupid=False): - self._load_fixture_and_fetch('no-author.svndump', stupid=stupid) + repo, repo_path = self.load_and_fetch('no-author.svndump', + stupid=stupid) users = set(self.repo[r].user() for r in self.repo) expected_users = ['(no author)@%s' % self.repo.svnmeta().uuid] self.assertEqual(sorted(users), expected_users) @@ -78,7 +79,7 @@ class MapTests(test_util.TestBase): authormap.close() ui = self.ui(stupid) ui.setconfig('hgsubversion', 'authormap', self.authors) - commands.clone(ui, test_util.fileurl(self.repo_path), + commands.clone(ui, test_util.fileurl(repo_path), self.wc_path, authors=self.authors) users = set(self.repo[r].user() for r in self.repo) expected_users = ['Testy '] @@ -327,8 +328,8 @@ class MapTests(test_util.TestBase): self.test_tagren_changed(True) def test_empty_log_message(self, stupid=False): - repo = self._load_fixture_and_fetch('empty-log-message.svndump', - stupid=stupid) + repo, repo_path = self.load_and_fetch('empty-log-message.svndump', + stupid=stupid) self.assertEqual(repo['tip'].description(), '') @@ -336,7 +337,7 @@ class MapTests(test_util.TestBase): ui = self.ui(stupid) ui.setconfig('hgsubversion', 'defaultmessage', 'blyf') - commands.clone(ui, test_util.fileurl(self.repo_path), self.wc_path) + commands.clone(ui, test_util.fileurl(repo_path), self.wc_path) self.assertEqual(self.repo['tip'].description(), 'blyf') diff --git a/tests/test_rebuildmeta.py b/tests/test_rebuildmeta.py --- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -28,7 +28,8 @@ def _do_case(self, name, stupid, single) layout = 'auto' if single: layout = 'single' - self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout) + repo, repo_path = self.load_and_fetch(name, subdir=subdir, stupid=stupid, + layout=layout) assert len(self.repo) > 0 wc2_path = self.wc_path + '_clone' u = ui.ui() @@ -44,7 +45,7 @@ def _do_case(self, name, stupid, single) try: svncommands.rebuildmeta(u, dest, - args=[test_util.fileurl(self.repo_path + + args=[test_util.fileurl(repo_path + subdir), ]) finally: # remove the wrapper diff --git a/tests/test_tags.py b/tests/test_tags.py --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -105,8 +105,8 @@ rename a tag self.test_most_recent_is_edited(True) def test_most_recent_is_edited(self, stupid=False): - repo = self._load_fixture_and_fetch('most-recent-is-edit-tag.svndump', - stupid=stupid) + repo, repo_path = self.load_and_fetch('most-recent-is-edit-tag.svndump', + stupid=stupid) self.repo.ui.status( "Note: this test failing may be because of a rebuildmeta failure.\n" "You should check that before assuming issues with this test.\n") @@ -114,7 +114,7 @@ rename a tag src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False) svncommands.rebuildmeta(repo.ui, dest, - args=[test_util.fileurl(self.repo_path), ]) + args=[test_util.fileurl(repo_path), ]) commands.pull(self.repo.ui, self.repo, stupid=stupid) dtags, srctags = dest.tags(), self.repo.tags() dtags.pop('tip') diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -269,9 +269,9 @@ class TestBase(unittest.TestCase): proc.communicate() return path - def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, - layout='auto', startrev=0, externals=None, - noupdate=True): + def load_and_fetch(self, fixture_name, subdir=None, stupid=False, + layout='auto', startrev=0, externals=None, + noupdate=True): if layout == 'single': if subdir is None: subdir = 'trunk' @@ -298,7 +298,11 @@ class TestBase(unittest.TestCase): dispatch(cmd) - return hg.repository(testui(), self.wc_path) + return hg.repository(testui(), self.wc_path), repo_path + + def _load_fixture_and_fetch(self, *args, **kwargs): + repo, repo_path = self.load_and_fetch(*args, **kwargs) + return repo def _add_svn_rev(self, changes): '''changes is a dict of filename -> contents''' diff --git a/tests/test_utility_commands.py b/tests/test_utility_commands.py --- a/tests/test_utility_commands.py +++ b/tests/test_utility_commands.py @@ -25,13 +25,12 @@ Last Changed Rev: %(rev)s Last Changed Date: %(date)s ''' -class UtilityTests(test_util.TestBase): - @property - def repourl(self): - return util.normalize_url(test_util.fileurl(self.repo_path)) +def repourl(repo_path): + return util.normalize_url(test_util.fileurl(repo_path)) +class UtilityTests(test_util.TestBase): def test_info_output(self): - self._load_fixture_and_fetch('two_heads.svndump') + repo, repo_path = self.load_and_fetch('two_heads.svndump') hg.update(self.repo, 'the_branch') u = self.ui() u.pushbuffer() @@ -39,7 +38,7 @@ class UtilityTests(test_util.TestBase): actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', - 'repourl': self.repourl, + 'repourl': repourl(repo_path), 'branch': 'branches/the_branch', 'rev': 5, }) @@ -50,7 +49,7 @@ class UtilityTests(test_util.TestBase): actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', - 'repourl': self.repourl, + 'repourl': repourl(repo_path), 'branch': 'trunk', 'rev': 6, }) @@ -61,14 +60,14 @@ class UtilityTests(test_util.TestBase): actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', - 'repourl': self.repourl, + 'repourl': repourl(repo_path), 'branch': 'branches/the_branch', 'rev': 5, }) self.assertMultiLineEqual(actual, expected) def test_info_single(self): - self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') + repo, repo_path = self.load_and_fetch('two_heads.svndump', subdir='trunk') hg.update(self.repo, 'tip') u = self.ui() u.pushbuffer() @@ -76,7 +75,7 @@ class UtilityTests(test_util.TestBase): actual = u.popbuffer() expected = (expected_info_output % {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', - 'repourl': self.repourl, + 'repourl': repourl(repo_path), 'branch': 'trunk', 'rev': 6, }) @@ -153,7 +152,7 @@ class UtilityTests(test_util.TestBase): self.assertEqual(actual, '4:1083037b18d8\n') def test_outgoing_output(self): - self._load_fixture_and_fetch('two_heads.svndump') + repo, repo_path = self.load_and_fetch('two_heads.svndump') u = self.ui() parents = (self.repo['the_branch'].node(), revlog.nullid,) def filectxfn(repo, memctx, path): @@ -173,13 +172,13 @@ class UtilityTests(test_util.TestBase): new = self.repo.commitctx(ctx) hg.update(self.repo, new) u.pushbuffer() - commands.outgoing(u, self.repo, self.repourl) + commands.outgoing(u, self.repo, repourl(repo_path)) actual = u.popbuffer() self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual) self.assertEqual(actual.strip(), '5:6de15430fa20') hg.update(self.repo, 'default') u.pushbuffer() - commands.outgoing(u, self.repo, self.repourl) + commands.outgoing(u, self.repo, repourl(repo_path)) actual = u.popbuffer() self.assertEqual(actual, '')