changeset 720:a19a208c085b

test_util: new requiresmodule decorator for tests that require a feature
author Augie Fackler <durin42@gmail.com>
date Mon, 04 Oct 2010 23:03:12 -0500
parents ae52a3b30cfb
children af817963897e
files tests/test_util.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -106,6 +106,15 @@ def _makeskip(name, message):
     return skip
 
 
+def requiresmodule(mod):
+    """Skip a test if the specified module is not None."""
+    def decorator(fn):
+        if mod is not None:
+            return fn
+        return _makeskip(fn.__name__, 'missing required feature')
+    return decorator
+
+
 def requiresoption(option):
     '''Skip a test if commands.clone does not take the specified option.'''
     def decorator(fn):