def doctest_skip_parser(func):
 lines = func.__doc__.split('\n')
 new_lines = []
 for line in lines:
  match = SKIP_RE.match(line)
  if (match is None):
   new_lines.append(line)
   continue
  (code, space, expr) = match.groups()
  try:
   if eval(expr, func.__globals__):
    code = ((code + space) + '# doctest: +SKIP')
  except AttributeError:
   if eval(expr, func.__init__.__globals__):
    code = ((code + space) + '# doctest: +SKIP')
  new_lines.append(code)
 func.__doc__ = '\n'.join(new_lines)
 return func

def doctest_skip_parser ( func ) : lines = func . __doc__ . split ( '\n' ) new_lines = [ ] for line in lines : match = SKIP_RE . match ( line ) if ( match is None ) : new_lines . append ( line ) continue ( code , space , expr ) = match . groups ( ) try : if eval ( expr , func . __globals__ ) : code = ( ( code + space ) + '# doctest: +SKIP' ) except AttributeError : if eval ( expr , func . __init__ . __globals__ ) : code = ( ( code + space ) + '# doctest: +SKIP' ) new_lines . append ( code ) func . __doc__ = '\n' . join ( new_lines ) return func
decorator replaces custom skip test markup in doctests say a function has a docstring:: .