comparison tests/comprehensive/test_custom_layout.py @ 1106:5cb6c95e0283 stable

Merge default and stable so I can do stable releases again.
author Augie Fackler <raf@durin42.com>
date Tue, 11 Feb 2014 12:48:49 -0500
parents cd0d14e25757
children ff4e102932ed
comparison
equal deleted inserted replaced
1020:b5b1fce26f1f 1106:5cb6c95e0283
1 import os
2 import pickle
3 import sys
4 import unittest
5
6 from mercurial import hg
7 from mercurial import ui
8
9 # wrapped in a try/except because of weirdness in how
10 # run.py works as compared to nose.
11 try:
12 import test_util
13 except ImportError:
14 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
15 import test_util
16
17 from hgsubversion import wrappers
18
19
20 def _do_case(self, name, stupid):
21 subdir = test_util.subdir.get(name, '')
22 config = {
23 'hgsubversion.stupid': stupid and '1' or '0',
24 }
25 repo, repo_path = self.load_and_fetch(name,
26 subdir=subdir,
27 layout='auto',
28 config=config)
29 assert test_util.repolen(self.repo) > 0, \
30 'Repo had no changes, maybe you need to add a subdir entry in test_util?'
31 wc2_path = self.wc_path + '_custom'
32 checkout_path = repo_path
33 if subdir:
34 checkout_path += '/' + subdir
35 u = ui.ui()
36 if stupid:
37 u.setconfig('hgsubversion', 'stupid', '1')
38 u.setconfig('hgsubversion', 'layout', 'custom')
39 for branch, path in test_util.custom.get(name, {}).iteritems():
40 u.setconfig('hgsubversionbranch', branch, path)
41 test_util.hgclone(u,
42 test_util.fileurl(checkout_path),
43 wc2_path,
44 update=False)
45 self.repo2 = hg.repository(ui.ui(), wc2_path)
46 self.assertEqual(self.repo.heads(), self.repo2.heads())
47
48
49 def buildmethod(case, name, stupid):
50 m = lambda self: self._do_case(case, stupid)
51 m.__name__ = name
52 replay = stupid and 'stupid' or 'regular'
53 m.__doc__ = 'Test custom produces same as standard on %s. (%s)' % (case,
54 replay)
55 return m
56
57 attrs = {'_do_case': _do_case,
58 }
59 for case in test_util.custom:
60 name = 'test_' + case[:-len('.svndump')].replace('-', '_')
61 attrs[name] = buildmethod(case, name, stupid=False)
62 name += '_stupid'
63 attrs[name] = buildmethod(case, name, stupid=True)
64
65 CustomPullTests = type('CustomPullTests', (test_util.TestBase,), attrs)