def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options):
 if (test_finder is None):
  test_finder = DocTestFinder()
 module = _normalize_module(module)
 tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
 if (globs is None):
  globs = module.__dict__
 if (not tests):
  raise ValueError(module, 'has no tests')
 tests.sort()
 suite = unittest.TestSuite()
 for test in tests:
  if (len(test.examples) == 0):
   continue
  if (not test.filename):
   filename = module.__file__
   if (filename[(-4):] in ('.pyc', '.pyo')):
    filename = filename[:(-1)]
   test.filename = filename
  suite.addTest(DocTestCase(test, **options))
 return suite

def DocTestSuite ( module = None , globs = None , extraglobs = None , test_finder = None , ** options ) : if ( test_finder is None ) : test_finder = DocTestFinder ( ) module = _normalize_module ( module ) tests = test_finder . find ( module , globs = globs , extraglobs = extraglobs ) if ( globs is None ) : globs = module . __dict__ if ( not tests ) : raise ValueError ( module , 'has no tests' ) tests . sort ( ) suite = unittest . TestSuite ( ) for test in tests : if ( len ( test . examples ) == 0 ) : continue if ( not test . filename ) : filename = module . __file__ if ( filename [ ( - 4 ) : ] in ( '.pyc' , '.pyo' ) ) : filename = filename [ : ( - 1 ) ] test . filename = filename suite . addTest ( DocTestCase ( test , ** options ) ) return suite
convert doctest tests for a module to a unittest test suite .