Mercurial > hgsubversion
changeset 716:38ebf7714cdf
requiresoption: raise SkipTest if available
This has the unfortunate (I guess?) side effect that you can no longer
use pure unittest to run skipped tests if nose or unittest2 is
installed.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 02 Oct 2010 16:44:37 -0500 |
parents | c33293a34752 |
children | ae5968ffe6fe |
files | tests/test_util.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -25,6 +25,14 @@ from mercurial import node from mercurial import ui from mercurial import extensions +try: + from unittest2 import SkipTest +except ImportError: + try: + from nose import SkipTest + except ImportError: + SkipTest = None + from hgsubversion import util # Documentation for Subprocess.Popen() says: @@ -94,6 +102,14 @@ def requiresoption(option): for entry in cmdutil.findcmd('clone', commands.table)[1][1]: if entry[1] == 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 + # no skipping support, so erase decorated method + return if not isinstance(option, str): raise TypeError('requiresoption takes a string argument') return decorator