def testsource(module, name):
 module = _normalize_module(module)
 tests = DocTestFinder().find(module)
 test = [t for t in tests if (t.name == name)]
 if (not test):
  raise ValueError(name, 'not found in tests')
 test = test[0]
 testsrc = script_from_examples(test.docstring)
 return testsrc

def testsource ( module , name ) : module = _normalize_module ( module ) tests = DocTestFinder ( ) . find ( module ) test = [ t for t in tests if ( t . name == name ) ] if ( not test ) : raise ValueError ( name , 'not found in tests' ) test = test [ 0 ] testsrc = script_from_examples ( test . docstring ) return testsrc
extract the test sources from a doctest docstring as a script .