comparison tests/test_pull.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 f28e0f54a6ef
children cc1c870f1758
comparison
equal deleted inserted replaced
864:39d45f2190ee 865:04729f3a3d17
9 9
10 class TestPull(test_util.TestBase): 10 class TestPull(test_util.TestBase):
11 def setUp(self): 11 def setUp(self):
12 super(TestPull, self).setUp() 12 super(TestPull, self).setUp()
13 13
14 def _load_fixture_and_fetch(self, fixture_name): 14 def _loadupdate(self, fixture_name):
15 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, 15 return self._load_fixture_and_fetch(fixture_name, stupid=False,
16 self.wc_path, stupid=False, 16 noupdate=False)
17 noupdate=False)
18 17
19 def test_nochanges(self): 18 def test_nochanges(self):
20 self._load_fixture_and_fetch('single_rev.svndump') 19 self._loadupdate('single_rev.svndump')
21 state = self.repo.parents() 20 state = self.repo.parents()
22 commands.pull(self.repo.ui, self.repo) 21 commands.pull(self.repo.ui, self.repo)
23 self.assertEqual(state, self.repo.parents()) 22 self.assertEqual(state, self.repo.parents())
24 23
25 def test_onerevision_noupdate(self): 24 def test_onerevision_noupdate(self):
26 repo = self._load_fixture_and_fetch('single_rev.svndump') 25 repo = self._loadupdate('single_rev.svndump')
27 state = repo.parents() 26 state = repo.parents()
28 self._add_svn_rev({'trunk/alpha': 'Changed'}) 27 self._add_svn_rev({'trunk/alpha': 'Changed'})
29 commands.pull(self.repo.ui, repo) 28 commands.pull(self.repo.ui, repo)
30 self.assertEqual(state, repo.parents()) 29 self.assertEqual(state, repo.parents())
31 self.assertTrue('tip' not in repo[None].tags()) 30 self.assertTrue('tip' not in repo[None].tags())
32 31
33 def test_onerevision_doupdate(self): 32 def test_onerevision_doupdate(self):
34 repo = self._load_fixture_and_fetch('single_rev.svndump') 33 repo = self._loadupdate('single_rev.svndump')
35 state = repo.parents() 34 state = repo.parents()
36 self._add_svn_rev({'trunk/alpha': 'Changed'}) 35 self._add_svn_rev({'trunk/alpha': 'Changed'})
37 commands.pull(self.repo.ui, repo, update=True) 36 commands.pull(self.repo.ui, repo, update=True)
38 self.failIfEqual(state, repo.parents()) 37 self.failIfEqual(state, repo.parents())
39 self.assertTrue('tip' in repo[None].tags()) 38 self.assertTrue('tip' in repo[None].tags())
40 39
41 def test_onerevision_divergent(self): 40 def test_onerevision_divergent(self):
42 repo = self._load_fixture_and_fetch('single_rev.svndump') 41 repo = self._loadupdate('single_rev.svndump')
43 self.commitchanges((('alpha', 'alpha', 'Changed another way'),)) 42 self.commitchanges((('alpha', 'alpha', 'Changed another way'),))
44 state = repo.parents() 43 state = repo.parents()
45 self._add_svn_rev({'trunk/alpha': 'Changed one way'}) 44 self._add_svn_rev({'trunk/alpha': 'Changed one way'})
46 try: 45 try:
47 commands.pull(self.repo.ui, repo, update=True) 46 commands.pull(self.repo.ui, repo, update=True)
51 self.assertEqual(state, repo.parents()) 50 self.assertEqual(state, repo.parents())
52 self.assertTrue('tip' not in repo[None].tags()) 51 self.assertTrue('tip' not in repo[None].tags())
53 self.assertEqual(len(repo.heads()), 2) 52 self.assertEqual(len(repo.heads()), 2)
54 53
55 def test_tag_repull_doesnt_happen(self): 54 def test_tag_repull_doesnt_happen(self):
56 repo = self._load_fixture_and_fetch('branchtagcollision.svndump') 55 repo = self._loadupdate('branchtagcollision.svndump')
57 oldheads = map(node.hex, repo.heads()) 56 oldheads = map(node.hex, repo.heads())
58 commands.pull(repo.ui, repo) 57 commands.pull(repo.ui, repo)
59 self.assertEqual(oldheads, map(node.hex, repo.heads())) 58 self.assertEqual(oldheads, map(node.hex, repo.heads()))
60 59
61 def suite(): 60 def suite():