def test_run_tests_if_main():
 x = []
 def test_a():
  x.append(True)
 @np.testing.dec.skipif(True)
 def test_b():
  return
 try:
  __name__ = '__main__'
  run_tests_if_main(measure_mem=False)
  def test_c():
   raise RuntimeError
  try:
   __name__ = '__main__'
   run_tests_if_main(measure_mem=False)
  except RuntimeError:
   pass
  else:
   raise RuntimeError('Error not raised')
 finally:
  del __name__
 assert_true((len(x) == 2))
 assert_true((x[0] and x[1]))

def test_run_tests_if_main ( ) : x = [ ] def test_a ( ) : x . append ( True ) @ np . testing . dec . skipif ( True ) def test_b ( ) : return try : __name__ = '__main__' run_tests_if_main ( measure_mem = False ) def test_c ( ) : raise RuntimeError try : __name__ = '__main__' run_tests_if_main ( measure_mem = False ) except RuntimeError : pass else : raise RuntimeError ( 'Error not raised' ) finally : del __name__ assert_true ( ( len ( x ) == 2 ) ) assert_true ( ( x [ 0 ] and x [ 1 ] ) )
test run_tests_if_main functionality .