(step: TStep, functions: FunctionsMapping)
preprocess for upload test
        replace `upload` info with MultipartEncoder

    Args:
        step: teststep
            {
                "variables": {},
                "request": {
                    "url": "http://httpbin.org/upload",
                    "method": "POST",
                    "headers": {
                        "Cookie": "session=AAA-BBB-CCC"
                    },
                    "upload": {
                        "file": "data/file_to_upload"
                        "md5": "123"
                    }
                }
            }
        functions: functions mapping
preprocess for upload test
        replace `upload` info with MultipartEncoder
preprocess for upload test replace upload info with MultipartEncoder
def prepare_upload_step(step: TStep, functions: FunctionsMapping) -> "NoReturn":
    """ preprocess for upload test
        replace `upload` info with MultipartEncoder

    Args:
        step: teststep
            {
                "variables": {},
                "request": {
                    "url": "http://httpbin.org/upload",
                    "method": "POST",
                    "headers": {
                        "Cookie": "session=AAA-BBB-CCC"
                    },
                    "upload": {
                        "file": "data/file_to_upload"
                        "md5": "123"
                    }
                }
            }
        functions: functions mapping

    """
    if not step.request.upload:
        return

    ensure_upload_ready()
    params_list = []
    for key, value in step.request.upload.items():
        step.variables[key] = value
        params_list.append(f"{key}=${key}")

    params_str = ", ".join(params_list)
    step.variables["m_encoder"] = "${multipart_encoder(" + params_str + ")}"

    # parse variables
    step.variables = parse_variables_mapping(step.variables, functions)

    step.request.headers["Content-Type"] = "${multipart_content_type($m_encoder)}"

    step.request.data = "$m_encoder"
def prepare_upload_step ( step : TStep , functions : FunctionsMapping ) -> "NoReturn" : if not step . request . upload : return ensure_upload_ready ( ) params_list = [ ] for key , value in step . request . upload . items ( ) : step . variables [ key ] = value params_list . append ( f"{key}=${key}" ) params_str = ", " . join ( params_list ) step . variables [ "m_encoder" ] = "${multipart_encoder(" + params_str + ")}" # parse variables step . variables = parse_variables_mapping ( step . variables , functions ) step . request . headers [ "Content-Type" ] = "${multipart_content_type($m_encoder)}" step . request . data = "$m_encoder"