mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 14:32:31 +08:00
change: make compatibility with Locust HttpSession
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
__version__ = "3.0.13"
|
__version__ = "3.1.0"
|
||||||
__description__ = "One-stop solution for HTTP(S) testing."
|
__description__ = "One-stop solution for HTTP(S) testing."
|
||||||
|
|
||||||
from httprunner.runner import HttpRunner
|
from httprunner.runner import HttpRunner
|
||||||
|
|||||||
@@ -203,24 +203,30 @@ class HttpRunner(object):
|
|||||||
|
|
||||||
# validate
|
# validate
|
||||||
validators = step.validators
|
validators = step.validators
|
||||||
|
session_success = False
|
||||||
try:
|
try:
|
||||||
resp_obj.validate(
|
resp_obj.validate(
|
||||||
validators, variables_mapping, self.__project_meta.functions
|
validators, variables_mapping, self.__project_meta.functions
|
||||||
)
|
)
|
||||||
self.__session.data.success = True
|
session_success = True
|
||||||
except ValidationFailure:
|
except ValidationFailure:
|
||||||
self.__session.data.success = False
|
session_success = False
|
||||||
log_req_resp_details()
|
log_req_resp_details()
|
||||||
# log testcase duration before raise ValidationFailure
|
# log testcase duration before raise ValidationFailure
|
||||||
self.__duration = time.time() - self.__start_at
|
self.__duration = time.time() - self.__start_at
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
# save request & response meta data
|
self.success = session_success
|
||||||
self.__session.data.validators = resp_obj.validation_results
|
step_data.success = session_success
|
||||||
self.success = self.__session.data.success
|
|
||||||
# save step data
|
if hasattr(self.__session, "data"):
|
||||||
step_data.success = self.__session.data.success
|
# httprunner.client.HttpSession, not locust.clients.HttpSession
|
||||||
step_data.data = self.__session.data
|
# save request & response meta data
|
||||||
|
self.__session.data.success = session_success
|
||||||
|
self.__session.data.validators = resp_obj.validation_results
|
||||||
|
|
||||||
|
# save step data
|
||||||
|
step_data.data = self.__session.data
|
||||||
|
|
||||||
return step_data
|
return step_data
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "httprunner"
|
name = "httprunner"
|
||||||
version = "3.0.13"
|
version = "3.1.0"
|
||||||
description = "One-stop solution for HTTP(S) testing."
|
description = "One-stop solution for HTTP(S) testing."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Reference in New Issue
Block a user