Improve websupport test skipping, add new decorator for search adapter skipping.

This commit is contained in:
Georg Brandl
2010-08-21 23:03:06 +02:00
parent 9acc57b616
commit 2f2a09c919
3 changed files with 30 additions and 18 deletions

View File

@@ -29,8 +29,8 @@ from nose import tools, SkipTest
__all__ = [
'test_root',
'raises', 'raises_msg', 'skip_if', 'skip_unless', 'Struct',
'test_root', 'raises', 'raises_msg',
'skip_if', 'skip_unless', 'skip_unless_importable', 'Struct',
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
'path', 'with_tempdir', 'write_file',
'sprint', 'remove_unicode_literals',
@@ -86,6 +86,15 @@ def skip_unless(condition, msg=None):
"""Decorator to skip test if condition is false."""
return skip_if(not condition, msg)
def skip_unless_importable(module, msg=None):
"""Decorator to skip test if module is not importable."""
try:
__import__(module)
except ImportError:
return skip_if(True, msg)
else:
return skip_if(False, msg)
class Struct(object):
def __init__(self, **kwds):