# HG changeset patch # User Augie Fackler # Date 1286251335 18000 # Node ID ae52a3b30cfb30461e8917549208eda50a441f4b # Parent db0eb6237420293133aa7f11d155c5e000eaa9eb test_util: refactor requiresoption to ease creation of other skip decorators diff --git a/tests/test_util.py b/tests/test_util.py --- 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):