fix: display validators in report when validate raised exception

This commit is contained in:
debugtalk
2019-12-25 23:21:10 +08:00
parent 891d81ddbf
commit e5bc23e4cf
4 changed files with 17 additions and 7 deletions

View File

@@ -1,5 +1,15 @@
# Release History # Release History
## 2.4.9 (2019-12-25)
**Added**
- test: add unittest for cli
**Fixed**
- fix: display validators in report when validate raised exception
## 2.4.8 (2019-12-25) ## 2.4.8 (2019-12-25)
**Added** **Added**

View File

@@ -1,4 +1,4 @@
__version__ = "2.4.8" __version__ = "2.4.9"
__description__ = "One-stop solution for HTTP(S) testing." __description__ = "One-stop solution for HTTP(S) testing."
__all__ = ["__version__", "__description__"] __all__ = ["__version__", "__description__"]

View File

@@ -303,8 +303,8 @@ class Runner(object):
except exceptions.ValidationFailure: except exceptions.ValidationFailure:
log_req_resp_details() log_req_resp_details()
raise raise
finally:
return validator.validation_results self.validation_results = validator.validation_results
def _run_testcase(self, testcase_dict): def _run_testcase(self, testcase_dict):
""" run single testcase. """ run single testcase.
@@ -382,9 +382,9 @@ class Runner(object):
self._run_testcase(test_dict) self._run_testcase(test_dict)
else: else:
# api # api
validation_results = {} self.validation_results = {}
try: try:
validation_results = self._run_test(test_dict) self._run_test(test_dict)
except Exception: except Exception:
# log exception request_type and name for locust stat # log exception request_type and name for locust stat
self.exception_request_type = test_dict["request"]["method"] self.exception_request_type = test_dict["request"]["method"]
@@ -393,7 +393,7 @@ class Runner(object):
finally: finally:
# get request/response data and validate results # get request/response data and validate results
self.meta_datas = getattr(self.http_client_session, "meta_data", {}) self.meta_datas = getattr(self.http_client_session, "meta_data", {})
self.meta_datas["validators"] = validation_results self.meta_datas["validators"] = self.validation_results
def export_variables(self, output_variables_list): def export_variables(self, output_variables_list):
""" export current testcase variables """ export current testcase variables

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "httprunner" name = "httprunner"
version = "2.4.8" version = "2.4.9"
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"