def run_tests(options, args): suite = unittest.TestSuite() if args: if args[0] == 'teardown': test_env.TestEnv().tearDown() exit(0) for arg in args: if hasattr(nocache_tests.TestNocache, arg): suite.addTest(nocache_tests.TestNocache(arg)) elif hasattr(stream_tests.TestStream, arg): suite.addTest(stream_tests.TestStream(arg)) elif hasattr(cache_tests.TestCache, arg) and options.memcache: suite.addTest(cache_tests.TestCache(arg)) elif hasattr(cache_tests.TestWillNotBeCached, arg) and options.memcache: suite.addTest(cache_tests.TestWillNotBeCached(arg)) else: raise Exception(arg, 'not found in tests') else: modules = [nocache_tests, stream_tests, status_tests] if options.memcache: modules.append(cache_tests) for m in modules: suite.addTests(unittest.TestLoader().loadTestsFromModule(m)) env = test_env.TestEnv() try: env.memcache = options.memcache env.setUp() print 'Starting queryservice_test.py' sys.stdout.flush() framework.TestCase.setenv(env) result = unittest.TextTestRunner(verbosity=options.verbose, failfast=True).run(suite) if not result.wasSuccessful(): raise Exception('test failures') finally: if not options.skip_teardown: env.tearDown() if options.keep_logs: print( 'Leaving temporary files behind (--keep-logs), please ' 'clean up before next run: ' + os.environ['VTDATAROOT'])
dest="verbose", default=0) parser.add_option("--no-build", action="store_true") (options, args) = parser.parse_args() utils.options = options logging.getLogger().setLevel(logging.ERROR) suite = unittest.TestSuite() if args: for arg in args: if hasattr(nocache_tests.TestNocache, arg): suite.addTest(nocache_tests.TestNocache(arg)) elif hasattr(stream_tests.TestStream, arg): suite.addTest(stream_tests.TestStream(arg)) elif hasattr(cache_tests.TestCache, arg) and options.memcache: suite.addTest(cache_tests.TestCache(arg)) elif hasattr(cache_tests.TestWillNotBeCached, arg) and options.memcache: suite.addTest(cache_tests.TestWillNotBeCached(arg)) else: raise Exception(arg, "not found in tests") else: suite.addTests( unittest.TestLoader().loadTestsFromModule(nocache_tests)) suite.addTests(unittest.TestLoader().loadTestsFromModule(stream_tests)) if options.memcache: suite.addTests( unittest.TestLoader().loadTestsFromModule(cache_tests)) for env_name in options.env.split(','):