(test_dict, api_def_dict)
return test_dict
extend test with api definition, test will merge and override api definition.

    Args:
        test_dict (dict): test block
        api_def_dict (dict): api definition

    Returns:
        dict: extended test dict.

    Examples:
        >>> api_def_dict = {
                "name": "get token 1",
                "request": {...},
                "validate": [{'eq': ['status_code', 200]}]
            }
        >>> test_dict = {
                "name": "get token 2",
                "extract": {"token": "content.token"},
                "validate": [{'eq': ['status_code', 201]}, {'len_eq': ['content.token', 16]}]
            }
        >>> _extend_with_api(test_dict, api_def_dict)
            {
                "name": "get token 2",
                "request": {...},
                "extract": {"token": "content.token"},
                "validate": [{'eq': ['status_code', 201]}, {'len_eq': ['content.token', 16]}]
            }
extend test with api definition, test will merge and override api definition.
extend test with api definition test will merge and override api definition .
def _extend_with_api(test_dict, api_def_dict):
    """ extend test with api definition, test will merge and override api definition.

    Args:
        test_dict (dict): test block
        api_def_dict (dict): api definition

    Returns:
        dict: extended test dict.

    Examples:
        >>> api_def_dict = {
                "name": "get token 1",
                "request": {...},
                "validate": [{'eq': ['status_code', 200]}]
            }
        >>> test_dict = {
                "name": "get token 2",
                "extract": {"token": "content.token"},
                "validate": [{'eq': ['status_code', 201]}, {'len_eq': ['content.token', 16]}]
            }
        >>> _extend_with_api(test_dict, api_def_dict)
            {
                "name": "get token 2",
                "request": {...},
                "extract": {"token": "content.token"},
                "validate": [{'eq': ['status_code', 201]}, {'len_eq': ['content.token', 16]}]
            }

    """
    # override name
    api_def_name = api_def_dict.pop("name", "")
    test_dict["name"] = test_dict.get("name") or api_def_name

    # override variables
    def_variables = api_def_dict.pop("variables", [])
    test_dict["variables"] = utils.extend_variables(
        def_variables,
        test_dict.get("variables", {})
    )

    # merge & override validators TODO: relocate
    def_raw_validators = api_def_dict.pop("validate", [])
    ref_raw_validators = test_dict.get("validate", [])
    def_validators = [
        parse_validator(validator)
        for validator in def_raw_validators
    ]
    ref_validators = [
        parse_validator(validator)
        for validator in ref_raw_validators
    ]
    test_dict["validate"] = utils.extend_validators(
        def_validators,
        ref_validators
    )

    # merge & override extractors
    def_extrators = api_def_dict.pop("extract", {})
    test_dict["extract"] = utils.extend_variables(
        def_extrators,
        test_dict.get("extract", {})
    )

    # TODO: merge & override request
    test_dict["request"] = api_def_dict.pop("request", {})

    # base_url & verify: priority api_def_dict > test_dict
    if api_def_dict.get("base_url"):
        test_dict["base_url"] = api_def_dict["base_url"]

    if "verify" in api_def_dict:
        test_dict["request"]["verify"] = api_def_dict["verify"]

    # merge & override setup_hooks
    def_setup_hooks = api_def_dict.pop("setup_hooks", [])
    ref_setup_hooks = test_dict.get("setup_hooks", [])
    extended_setup_hooks = list(set(def_setup_hooks + ref_setup_hooks))
    if extended_setup_hooks:
        test_dict["setup_hooks"] = extended_setup_hooks
    # merge & override teardown_hooks
    def_teardown_hooks = api_def_dict.pop("teardown_hooks", [])
    ref_teardown_hooks = test_dict.get("teardown_hooks", [])
    extended_teardown_hooks = list(set(def_teardown_hooks + ref_teardown_hooks))
    if extended_teardown_hooks:
        test_dict["teardown_hooks"] = extended_teardown_hooks

    # TODO: extend with other api definition items, e.g. times
    test_dict.update(api_def_dict)

    return test_dict
def _extend_with_api ( test_dict , api_def_dict ) : # override name api_def_name = api_def_dict . pop ( "name" , "" ) test_dict [ "name" ] = test_dict . get ( "name" ) or api_def_name # override variables def_variables = api_def_dict . pop ( "variables" , [ ] ) test_dict [ "variables" ] = utils . extend_variables ( def_variables , test_dict . get ( "variables" , { } ) ) # merge & override validators TODO: relocate def_raw_validators = api_def_dict . pop ( "validate" , [ ] ) ref_raw_validators = test_dict . get ( "validate" , [ ] ) def_validators = [ parse_validator ( validator ) for validator in def_raw_validators ] ref_validators = [ parse_validator ( validator ) for validator in ref_raw_validators ] test_dict [ "validate" ] = utils . extend_validators ( def_validators , ref_validators ) # merge & override extractors def_extrators = api_def_dict . pop ( "extract" , { } ) test_dict [ "extract" ] = utils . extend_variables ( def_extrators , test_dict . get ( "extract" , { } ) ) # TODO: merge & override request test_dict [ "request" ] = api_def_dict . pop ( "request" , { } ) # base_url & verify: priority api_def_dict > test_dict if api_def_dict . get ( "base_url" ) : test_dict [ "base_url" ] = api_def_dict [ "base_url" ] if "verify" in api_def_dict : test_dict [ "request" ] [ "verify" ] = api_def_dict [ "verify" ] # merge & override setup_hooks def_setup_hooks = api_def_dict . pop ( "setup_hooks" , [ ] ) ref_setup_hooks = test_dict . get ( "setup_hooks" , [ ] ) extended_setup_hooks = list ( set ( def_setup_hooks + ref_setup_hooks ) ) if extended_setup_hooks : test_dict [ "setup_hooks" ] = extended_setup_hooks # merge & override teardown_hooks def_teardown_hooks = api_def_dict . pop ( "teardown_hooks" , [ ] ) ref_teardown_hooks = test_dict . get ( "teardown_hooks" , [ ] ) extended_teardown_hooks = list ( set ( def_teardown_hooks + ref_teardown_hooks ) ) if extended_teardown_hooks : test_dict [ "teardown_hooks" ] = extended_teardown_hooks # TODO: extend with other api definition items, e.g. times test_dict . update ( api_def_dict ) return test_dict