def _create_suite(request):
    global _cached_suite
    package_name = request.get("package")
    test_name = request.get("name")

    loader = unittest.defaultTestLoader
    suite = unittest.TestSuite()

    error = None

    try:
        if not package_name and not test_name:
            if _cached_suite:
                return (_cached_suite, None)
            modules = _load_default_test_modules()
            for module in modules:
                suite.addTest(loader.loadTestsFromModule(module))
        elif test_name:
            _load_default_test_modules()
            suite.addTest(loader.loadTestsFromName(test_name))
        elif package_name:
            package = reload(__import__(package_name))
            module_names = package.__all__
            for module_name in module_names:
                suite.addTest(loader.loadTestsFromName(
                    '%s.%s' % (package_name, module_name)))
    
        if suite.countTestCases() == 0:
            raise Exception("does not contain any tests.")
    except Exception, e:
        import sys
        import traceback
        error = '\n'.join(traceback.format_exception(*(sys.exc_info())))
        error = str(error)
        _log_error(error)
    if error is None:
      _cached_suite = suite
    return (suite, error)
dataset/ETHPy150Open IanLewis/kay/kay/ext/testutils/gaeunit.py/_create_suite/original