diff tests/test_util.py @ 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 e830b592917b
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):