1474
|
1 import os |
|
2 import unittest |
|
3 import sys |
|
4 |
|
5 # wrapped in a try/except because of weirdness in how |
|
6 # run.py works as compared to nose. |
|
7 try: |
|
8 import test_util |
|
9 except ImportError: |
|
10 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
|
11 import test_util |
|
12 |
|
13 # interesting and fast tests |
|
14 import test_fetch_mappings |
|
15 import test_fetch_renames |
|
16 import test_pull |
|
17 import test_template_keywords |
|
18 import test_utility_commands |
|
19 |
|
20 # comprehensive tests |
|
21 try: |
|
22 import test_custom_layout |
|
23 except ImportError: |
|
24 sys.path.insert(0, os.path.dirname(__file__)) |
|
25 import test_custom_layout |
|
26 |
|
27 import test_rebuildmeta |
|
28 import test_updatemeta |
|
29 |
|
30 from hgsubversion import svnmeta, maps |
|
31 |
|
32 |
|
33 class SqliteRevMapMixIn(object): |
|
34 # do not double the test size by being wrapped again |
|
35 obsolete_mode_tests = False |
|
36 stupid_mode_tests = False |
|
37 |
|
38 def setUp(self): |
|
39 assert svnmeta.SVNMeta._defaultrevmapclass is maps.RevMap |
|
40 svnmeta.SVNMeta._defaultrevmapclass = maps.SqliteRevMap |
|
41 super(SqliteRevMapMixIn, self).setUp() |
|
42 |
|
43 def tearDown(self): |
|
44 assert svnmeta.SVNMeta._defaultrevmapclass is maps.SqliteRevMap |
|
45 svnmeta.SVNMeta._defaultrevmapclass = maps.RevMap |
|
46 super(SqliteRevMapMixIn, self).tearDown() |
|
47 |
|
48 def shortDescription(self): |
|
49 text = super(SqliteRevMapMixIn, self).shortDescription() |
|
50 if text: |
|
51 text += ' (sqlite revmap)' |
|
52 return text |
|
53 |
|
54 def buildtestclass(cls, selector=None): |
|
55 name = 'SqliteRevMap%s' % cls.__name__ |
|
56 newcls = type(name, (SqliteRevMapMixIn, cls,), {}) |
|
57 |
|
58 # remove test cases not selected by selector |
|
59 if selector: |
|
60 for name in dir(newcls): |
|
61 if name.startswith('test_') and not selector(name[5:]): |
|
62 setattr(newcls, name, None) |
|
63 |
|
64 globals()[name] = newcls |
|
65 |
|
66 def svndumpselector(name): |
|
67 return name in ['branch_rename_to_trunk', |
|
68 'tag_name_same_as_branch'] |
|
69 |
|
70 buildtestclass(test_fetch_mappings.MapTests) |
|
71 buildtestclass(test_fetch_renames.TestFetchRenames) |
|
72 buildtestclass(test_pull.TestPull) |
|
73 buildtestclass(test_template_keywords.TestLogKeywords) |
|
74 buildtestclass(test_utility_commands.UtilityTests) |
|
75 |
|
76 buildtestclass(test_rebuildmeta.RebuildMetaTests, svndumpselector) |
|
77 buildtestclass(test_updatemeta.UpdateMetaTests, svndumpselector) |