def load_testsuite(loader, dir):
 suite = unittest.TestSuite()
 files = []
 for f in os.listdir(dir):
  path = join(dir, f)
  if (isfile(path) and fnmatch(f, 'test_*.py')):
   files.append(f)
  elif isfile(join(path, '__init__.py')):
   suite.addTests(loader.discover(path))
 for f in files:
  f = relpath(join(dir, f), loader._top_level_dir)
  f = splitext(normpath(f.replace(os.path.sep, '.')))[0]
  suite.addTests(loader.loadTestsFromName(f))
 return suite

def load_testsuite ( loader , dir ) : suite = unittest . TestSuite ( ) files = [ ] for f in os . listdir ( dir ) : path = join ( dir , f ) if ( isfile ( path ) and fnmatch ( f , 'test_*.py' ) ) : files . append ( f ) elif isfile ( join ( path , '__init__.py' ) ) : suite . addTests ( loader . discover ( path ) ) for f in files : f = relpath ( join ( dir , f ) , loader . _top_level_dir ) f = splitext ( normpath ( f . replace ( os . path . sep , '.' ) ) ) [ 0 ] suite . addTests ( loader . loadTestsFromName ( f ) ) return suite
find tests in dir .