(validator)
return {
        "check": check_item,
        "expect": expect_value,
        "comparator": comparator
    }
parse validator

    Args:
        validator (dict): validator maybe in two formats:

            format1: this is kept for compatiblity with the previous versions.
                {"check": "status_code", "comparator": "eq", "expect": 201}
                {"check": "$resp_body_success", "comparator": "eq", "expect": True}
            format2: recommended new version
                {'eq': ['status_code', 201]}
                {'eq': ['$resp_body_success', True]}

    Returns
        dict: validator info

            {
                "check": "status_code",
                "expect": 201,
                "comparator": "eq"
            }
parse validator
parse validator
def parse_validator(validator):
    """ parse validator

    Args:
        validator (dict): validator maybe in two formats:

            format1: this is kept for compatiblity with the previous versions.
                {"check": "status_code", "comparator": "eq", "expect": 201}
                {"check": "$resp_body_success", "comparator": "eq", "expect": True}
            format2: recommended new version
                {'eq': ['status_code', 201]}
                {'eq': ['$resp_body_success', True]}

    Returns
        dict: validator info

            {
                "check": "status_code",
                "expect": 201,
                "comparator": "eq"
            }

    """
    if not isinstance(validator, dict):
        raise exceptions.ParamsError("invalid validator: {}".format(validator))

    if "check" in validator and len(validator) > 1:
        # format1
        check_item = validator.get("check")

        if "expect" in validator:
            expect_value = validator.get("expect")
        elif "expected" in validator:
            expect_value = validator.get("expected")
        else:
            raise exceptions.ParamsError("invalid validator: {}".format(validator))

        comparator = validator.get("comparator", "eq")

    elif len(validator) == 1:
        # format2
        comparator = list(validator.keys())[0]
        compare_values = validator[comparator]

        if not isinstance(compare_values, list) or len(compare_values) != 2:
            raise exceptions.ParamsError("invalid validator: {}".format(validator))

        check_item, expect_value = compare_values

    else:
        raise exceptions.ParamsError("invalid validator: {}".format(validator))

    return {
        "check": check_item,
        "expect": expect_value,
        "comparator": comparator
    }
def parse_validator ( validator ) : if not isinstance ( validator , dict ) : raise exceptions . ParamsError ( "invalid validator: {}" . format ( validator ) ) if "check" in validator and len ( validator ) > 1 : # format1 check_item = validator . get ( "check" ) if "expect" in validator : expect_value = validator . get ( "expect" ) elif "expected" in validator : expect_value = validator . get ( "expected" ) else : raise exceptions . ParamsError ( "invalid validator: {}" . format ( validator ) ) comparator = validator . get ( "comparator" , "eq" ) elif len ( validator ) == 1 : # format2 comparator = list ( validator . keys ( ) ) [ 0 ] compare_values = validator [ comparator ] if not isinstance ( compare_values , list ) or len ( compare_values ) != 2 : raise exceptions . ParamsError ( "invalid validator: {}" . format ( validator ) ) check_item , expect_value = compare_values else : raise exceptions . ParamsError ( "invalid validator: {}" . format ( validator ) ) return { "check" : check_item , "expect" : expect_value , "comparator" : comparator }