def if_matplotlib(func):
 @wraps(func)
 def run_test(*args, **kwargs):
  try:
   import matplotlib
   matplotlib.use('Agg', warn=False)
   import matplotlib.pyplot as plt
   plt.figure()
  except ImportError:
   raise SkipTest('Matplotlib not available.')
  else:
   return func(*args, **kwargs)
 return run_test

def if_matplotlib ( func ) : @ wraps ( func ) def run_test ( * args , ** kwargs ) : try : import matplotlib matplotlib . use ( 'Agg' , warn = False ) import matplotlib . pyplot as plt plt . figure ( ) except ImportError : raise SkipTest ( 'Matplotlib not available.' ) else : return func ( * args , ** kwargs ) return run_test
test decorator that skips test if matplotlib not installed .