def _choose_random_tests(tests, ratio, seed):
 rnd = random.Random()
 rnd.seed(seed)
 if isinstance(tests, unittest.TestSuite):
  tests = _flatten_suite(tests)
 tests = rnd.sample(tests, int((len(tests) * ratio)))
 tests = sorted(tests, key=(lambda case: case.id()))
 return unittest.TestSuite(tests)

def _choose_random_tests ( tests , ratio , seed ) : rnd = random . Random ( ) rnd . seed ( seed ) if isinstance ( tests , unittest . TestSuite ) : tests = _flatten_suite ( tests ) tests = rnd . sample ( tests , int ( ( len ( tests ) * ratio ) ) ) tests = sorted ( tests , key = ( lambda case : case . id ( ) ) ) return unittest . TestSuite ( tests )
choose a given proportion of tests at random .