Skip to content
This repository was archived by the owner on Jul 11, 2019. It is now read-only.
This repository was archived by the owner on Jul 11, 2019. It is now read-only.

自定义函数报错httprunner.exceptions.ExtractFailure: Failed to extract data with regex! => ${checkTime($response)} #145

Open

Description

@xuanyuexx

在extract中使用该函数取值 ${checkTime($response)}
在validate中验证返回值 equals
报错:httprunner.exceptions.ExtractFailure: Failed to extract data with regex! => ${checkTime($response)}

debugtalk.py 自定义函数如下:

def checkTime(response):
request_time = int(time)
result_json = json.loads(response.content)
response_time = int(result_json['result']['data'][0]['unixtime'])
return response_time
if sort == 'asc':
if response_time > request_time:
return request_time
else:
return response_time
else:
if response_time < request_time:
return response_time
else:
return request_time

Activity

  1. Verckolf commented on May 5, 2019

    @Verckolf

    我记得extract中不支持自定义的函数,但是断言是支持的,你可以在这里调用。或者你可以先用json提取出来,在后续的用例的参数中“自定义函数”提取你想要的的变量

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions