示例#1
0
def main(argv):
    parser = get_parser()
    args = parser.parse_args(argv[1:])
    logger = commandline.setup_logging("webapi", args, {"mach": sys.stdout})

    test_loader = TestLoader()
    tests = []
    if len(args.tests) >= 1 and args.tests[0] == "discover":
        start_dir = args.tests[1] if len(args.tests) > 1 else "."
        tests = test_loader.discover(start_dir, args.pattern or "test_*.py")
    else:
        tests = None
        if len(args.tests) > 0:
            tests = test_loader.loadTestsFromNames(args.tests, None)
        else:
            tests = unittest.TestSuite()

    results = run(tests,
                  spawn_browser=not args.no_browser,
                  verbosity=2 if args.verbose else 1,
                  failfast=args.failfast,
                  catch_break=args.catch,
                  buffer=args.buffer,
                  logger=logger)
    sys.exit(not results.wasSuccessful())
示例#2
0
def main():
    parser = argparse.ArgumentParser(
        description="Runner for guided Web API tests.")
    parser.add_argument("-l",
                        "--list-test-groups",
                        action="store_true",
                        help="List all logical test groups")
    parser.add_argument("-a",
                        "--list-all-tests",
                        action="store_true",
                        help="List all tests")
    parser.add_argument(
        "-i",
        "--include",
        metavar="GROUP",
        action="append",
        default=[],
        help="Only include specified group(s) in run, include several "
        "groups by repeating flag")
    parser.add_argument(
        "-n",
        "--no-browser",
        action="store_true",
        help="Don't start a browser but wait for manual connection")
    parser.add_argument("-v",
                        dest="verbose",
                        action="store_true",
                        help="Verbose output")
    commandline.add_logging_group(parser)
    args = parser.parse_args(sys.argv[1:])
    logger = commandline.setup_logging("webapi", vars(args),
                                       {"raw": sys.stdout})
    if args.list_test_groups and len(args.include) > 0:
        print >> sys.stderr("%s: error: cannot list and include test "
                            "groups at the same time" % sys.argv[0])
        parser.print_usage()
        sys.exit(1)

    testgen = iter_tests(os.path.dirname(__file__))
    if args.list_test_groups:
        for group, _ in testgen:
            print(group)
        return 0
    elif args.list_all_tests:
        for group, tests in testgen:
            for test in tests:
                print("%s.%s" % (group, test))
        return 0

    test_loader = semiauto.TestLoader()
    tests = test_loader.loadTestsFromNames(
        map(lambda t: "webapi_tests.%s" % t, args.include
            or [g for g, _ in testgen]), None)
    results = semiauto.run(tests,
                           logger=logger,
                           spawn_browser=not args.no_browser,
                           verbosity=2 if args.verbose else 1)
    return 0 if results.wasSuccessful() else 1
示例#3
0
def main():
    parser = argparse.ArgumentParser(
        description="Runner for guided Web API tests.")
    parser.add_argument("-l", "--list-test-groups", action="store_true",
                        help="List all logical test groups")
    parser.add_argument("-a", "--list-all-tests", action="store_true",
                        help="List all tests")
    parser.add_argument("-i", "--include", metavar="GROUP", action="append", default=[],
                        help="Only include specified group(s) in run, include several "
                        "groups by repeating flag")
    parser.add_argument("-n", "--no-browser", action="store_true",
                        help="Don't start a browser but wait for manual connection")
    parser.add_argument("--version", action="store", dest="version",
                        help="B2G version")
    parser.add_argument(
        "-v", dest="verbose", action="store_true", help="Verbose output")
    commandline.add_logging_group(parser)
    args = parser.parse_args(sys.argv[1:])
    logger = commandline.setup_logging(
        "webapi", vars(args), {"raw": sys.stdout})

    if args.list_test_groups and len(args.include) > 0:
        print >> sys.stderr("%s: error: cannot list and include test "
                            "groups at the same time" % sys.argv[0])
        parser.print_usage()
        sys.exit(1)

    testgen = iter_tests(os.path.dirname(__file__))
    if args.list_test_groups:
        for group, _ in testgen:
            print(group)
        return 0
    elif args.list_all_tests:
        for group, tests in testgen:
            for test in tests:
                print("%s.%s" % (group, test))
        return 0

    test_loader = semiauto.TestLoader(version=args.version)
    tests = test_loader.loadTestsFromNames(
        map(lambda t: "webapi_tests.%s" % t, args.include or [g for g, _ in testgen]), None)
    results = semiauto.run(tests,
                           logger=logger,
                           spawn_browser=not args.no_browser,
                           verbosity=2 if args.verbose else 1)
    return 0 if results.wasSuccessful() else 1