How to use the gabbi.utils.host_info_from_target function in gabbi

To help you get started, we’ve selected a few gabbi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cdent / gabbi / gabbi / runner.py View on Github external
turn on verbosity for all tests being run.

    Multiple files may be named as arguments, separated from other arguments
    by a ``--``. Each file will be run as a separate test suite::

        gabbi-run http://example.com -- /path/to/x.yaml /path/to/y.yaml

    Output is formatted as unittest summary information. Use `-q` or
    `--quiet` to silence that output.
    """
    parser = _make_argparser()

    argv, input_files = extract_file_paths(sys.argv)
    args = parser.parse_args(argv[1:])

    host, port, prefix, force_ssl = utils.host_info_from_target(
        args.target, args.prefix)

    handler_objects = initialize_handlers(args.response_handlers)

    quiet = args.quiet
    verbosity = args.verbosity
    failfast = args.failfast
    cert_validate = args.cert_validate
    failure = False
    # Keep track of file names that have failures.
    failures = []

    if not input_files:
        success = run_suite(sys.stdin, handler_objects, host, port,
                            prefix, force_ssl, failfast,
                            verbosity=verbosity,
github cdent / gabbi / gabbi / driver.py View on Github external
:param verbose: If ``True`` or ``'all'``, make tests verbose by default
                    ``'headers'`` and ``'body'`` are also accepted.
    :param use_prior_test: If ``True``, uses prior test to create ordered
                           sequence of tests
    :param safe_yaml: If ``True``, recognizes only standard YAML tags and not
                      Python object
    :param cert_validate: If ``False`` ssl server certificate will be ignored,
                        further it will not be validated if provided
                        (set cert_reqs=CERT_NONE to the Http object)
    :type inner_fixtures: List of fixtures.Fixture classes.
    :rtype: TestSuite containing multiple TestSuites (one for each YAML file).
    """

    # If url is being used, reset host, port and prefix.
    if url:
        host, port, prefix, force_ssl = utils.host_info_from_target(url)
        if force_ssl and not require_ssl:
            require_ssl = force_ssl

    # Exit immediately if we have no host to access, either via a real host
    # or an intercept.
    if not ((host is not None) ^ bool(intercept)):
        raise AssertionError(
            'must specify exactly one of host or url, or intercept')

    # If the client has not provided a name to use as our base,
    # create one so that tests are effectively namespaced.
    if test_loader_name is None:
        all_test_base_name = inspect.stack()[1]
        all_test_base_name = os.path.splitext(
            os.path.basename(all_test_base_name[1]))[0]
    else: