Mercurial > hgsubversion
comparison tests/test_util.py @ 711:cfc7df19e4dc
test_util: add requiresoption decorator function.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Wed, 29 Sep 2010 18:04:26 +0200 |
parents | 1f1a3a6730c1 |
children | c33293a34752 |
comparison
equal
deleted
inserted
replaced
710:db56e65906f4 | 711:cfc7df19e4dc |
---|---|
13 import urllib | 13 import urllib |
14 | 14 |
15 _rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 15 _rootdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
16 sys.path.insert(0, _rootdir) | 16 sys.path.insert(0, _rootdir) |
17 | 17 |
18 from mercurial import cmdutil | |
18 from mercurial import commands | 19 from mercurial import commands |
19 from mercurial import context | 20 from mercurial import context |
20 from mercurial import dispatch | 21 from mercurial import dispatch |
21 from mercurial import hg | 22 from mercurial import hg |
22 from mercurial import i18n | 23 from mercurial import i18n |
84 'project_name_with_space.svndump': '/project name', | 85 'project_name_with_space.svndump': '/project name', |
85 } | 86 } |
86 | 87 |
87 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), | 88 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), |
88 'fixtures') | 89 'fixtures') |
90 | |
91 def requiresoption(option): | |
92 ''' | |
93 Decorator for test functions which require clone to accept the given option. | |
94 If the option isn't available, the test is skipped. | |
95 | |
96 Takes one argument: the required option. | |
97 ''' | |
98 def decorator(fn): | |
99 for entry in cmdutil.findcmd('clone', commands.table)[1][1]: | |
100 if entry[1] == option: | |
101 return fn | |
102 if not isinstance(option, str): | |
103 raise TypeError('requiresoption takes a string argument') | |
104 return decorator | |
89 | 105 |
90 def filtermanifest(manifest): | 106 def filtermanifest(manifest): |
91 return filter(lambda x: x not in ('.hgtags', '.hgsvnexternals', ), | 107 return filter(lambda x: x not in ('.hgtags', '.hgsvnexternals', ), |
92 manifest) | 108 manifest) |
93 | 109 |