def RequiresPackage(package_name):
 def Decorator(test_function):
  @functools.wraps(test_function)
  def Wrapper(*args, **kwargs):
   try:
    pkg_resources.get_distribution(package_name)
   except pkg_resources.DistributionNotFound:
    raise unittest.SkipTest(('Skipping, package %s not installed' % package_name))
   return test_function(*args, **kwargs)
  return Wrapper
 return Decorator

def RequiresPackage ( package_name ) : def Decorator ( test_function ) : @ functools . wraps ( test_function ) def Wrapper ( * args , ** kwargs ) : try : pkg_resources . get_distribution ( package_name ) except pkg_resources . DistributionNotFound : raise unittest . SkipTest ( ( 'Skipping, package %s not installed' % package_name ) ) return test_function ( * args , ** kwargs ) return Wrapper return Decorator
skip this test if required package isnt present .