comparison tests/test_util.py @ 727:e830b592917b

tests: fix test skipping in pure unittest
author Augie Fackler <durin42@gmail.com>
date Fri, 08 Oct 2010 13:58:26 -0500
parents a19a208c085b
children e24fb3e27ec9
comparison
equal deleted inserted replaced
726:8d36054b04ed 727:e830b592917b
98 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), 98 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)),
99 'fixtures') 99 'fixtures')
100 100
101 101
102 def _makeskip(name, message): 102 def _makeskip(name, message):
103 def skip(*args, **kwargs): 103 if SkipTest:
104 raise SkipTest(message) 104 def skip(*args, **kwargs):
105 skip.__name__ = name 105 raise SkipTest(message)
106 return skip 106 skip.__name__ = name
107 107 return skip
108 108
109 def requiresmodule(mod): 109 def requiresmodule(mod):
110 """Skip a test if the specified module is not None.""" 110 """Skip a test if the specified module is not None."""
111 def decorator(fn): 111 def decorator(fn):
112 if fn is None:
113 return
112 if mod is not None: 114 if mod is not None:
113 return fn 115 return fn
114 return _makeskip(fn.__name__, 'missing required feature') 116 return _makeskip(fn.__name__, 'missing required feature')
115 return decorator 117 return decorator
116 118