comparison tests/comprehensive/test_stupid_pull.py @ 194:13ae1bded5e7

Add some comprehensive tests that can be run with nose in order to make it easier to verify stupid and real replay do the same thing.
author Augie Fackler <durin42@gmail.com>
date Wed, 21 Jan 2009 20:27:51 -0600
parents
children 906d3f302b45
comparison
equal deleted inserted replaced
193:6e3f99ba47ec 194:13ae1bded5e7
1 import os
2 import pickle
3 import unittest
4
5 from mercurial import hg
6 from mercurial import ui
7
8 from tests import test_util
9 import rebuildmeta
10 import hg_delta_editor
11 import fetch_command
12
13
14 def _do_case(self, name):
15 subdir = test_util.subdir.get(name, '')
16 self._load_fixture_and_fetch(name, subdir=subdir, stupid=False)
17 assert len(self.repo) > 0, 'Repo had no changes, maybe you need to add a subdir entry in test_util?'
18 wc2_path = self.wc_path + '_stupid'
19 u = ui.ui()
20 checkout_path = self.repo_path
21 if subdir:
22 checkout_path += '/' + subdir
23 fetch_command.fetch_revisions(ui.ui(),
24 svn_url=test_util.fileurl(checkout_path),
25 hg_repo_path=wc2_path,
26 stupid=True)
27 self.repo2 = hg.repository(ui.ui(), wc2_path)
28 self.assertEqual(self.repo.branchtags(), self.repo2.branchtags())
29 self.assertEqual(pickle.load(open(os.path.join(self.wc_path, '.hg', 'svn', 'tag_info'))),
30 pickle.load(open(os.path.join(wc2_path, '.hg', 'svn', 'tag_info'))))
31
32
33 def buildmethod(case, name):
34 m = lambda self: self._do_case(case)
35 m.__name__ = name
36 m.__doc__ = 'Test stupid produces same as real on %s.' % case
37 return m
38
39 attrs = {'_do_case': _do_case,
40 }
41 for case in (f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')):
42 name = 'test_' + case[:-len('.svndump')]
43 attrs[name] = buildmethod(case, name)
44 StupidPullTests = type('StupidPullTests', (test_util.TestBase, ), attrs)
45
46
47 def suite():
48 all = [unittest.TestLoader().loadTestsFromTestCase(StupidPullTests),
49 ]
50 return unittest.TestSuite(all)