def requires_module(function, name, call=None):
 call = (('import %s' % name) if (call is None) else call)
 try:
  from nose.plugins.skip import SkipTest
 except ImportError:
  SkipTest = AssertionError
 @wraps(function)
 def dec(*args, **kwargs):
  try:
   exec call in globals(), locals()
  except Exception as exc:
   raise SkipTest(('Test %s skipped, requires %s. Got exception (%s)' % (function.__name__, name, exc)))
  return function(*args, **kwargs)
 return dec

def requires_module ( function , name , call = None ) : call = ( ( 'import %s' % name ) if ( call is None ) else call ) try : from nose . plugins . skip import SkipTest except ImportError : SkipTest = AssertionError @ wraps ( function ) def dec ( * args , ** kwargs ) : try : exec call in globals ( ) , locals ( ) except Exception as exc : raise SkipTest ( ( 'Test %s skipped, requires %s. Got exception (%s)' % ( function . __name__ , name , exc ) ) ) return function ( * args , ** kwargs ) return dec
decorator to skip test if package is not available .