Mercurial > hgsubversion
changeset 719:ae52a3b30cfb
test_util: refactor requiresoption to ease creation of other skip decorators
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 04 Oct 2010 23:02:15 -0500 |
parents | db0eb6237420 |
children | a19a208c085b |
files | tests/test_util.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -98,6 +98,14 @@ subdir = {'truncatedhistory.svndump': '/ FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'fixtures') + +def _makeskip(name, message): + def skip(*args, **kwargs): + raise SkipTest(message) + skip.__name__ = name + return skip + + def requiresoption(option): '''Skip a test if commands.clone does not take the specified option.''' def decorator(fn): @@ -106,10 +114,8 @@ def requiresoption(option): return fn # no match found, so skip if SkipTest: - def skip(*args, **kwargs): - raise SkipTest('test requires clone to accept %s' % option) - skip.__name__ = fn.__name__ - return skip + return _makeskip(fn.__name__, + 'test requires clone to accept %s' % option) # no skipping support, so erase decorated method return if not isinstance(option, str):