diff --git a/httprunner/__about__.py b/httprunner/__about__.py index 4a8bceb5..30d339cc 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '1.5.11' +__version__ = '1.5.12' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/httprunner/context.py b/httprunner/context.py index 766aae22..24fdbab2 100644 --- a/httprunner/context.py +++ b/httprunner/context.py @@ -230,6 +230,7 @@ class Context(object): logger.log_info("start to validate.") validate_pass = True + failures = [] for validator in validators: # evaluate validators with context variable mapping. @@ -240,12 +241,14 @@ class Context(object): try: self._do_validation(evaluated_validator) - except exceptions.ValidationFailure: + except exceptions.ValidationFailure as ex: validate_pass = False + failures.append(str(ex)) evaluated_validators.append(evaluated_validator) if not validate_pass: - raise exceptions.ValidationFailure + failures_string = "\n".join([failure for failure in failures]) + raise exceptions.ValidationFailure(failures_string) return evaluated_validators diff --git a/httprunner/runner.py b/httprunner/runner.py index 7342a89a..16271b4d 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -214,8 +214,7 @@ class Runner(object): # validate try: self.evaluated_validators = self.context.validate(validators, resp_obj) - except (exceptions.ParamsError, \ - exceptions.ValidationFailure, exceptions.ExtractFailure): + except (exceptions.ParamsError, exceptions.ValidationFailure, exceptions.ExtractFailure): # log request err_req_msg = "request: \n" err_req_msg += "headers: {}\n".format(parsed_request.pop("headers", {})) diff --git a/httprunner/utils.py b/httprunner/utils.py index be0c6b75..1b037ec3 100644 --- a/httprunner/utils.py +++ b/httprunner/utils.py @@ -263,7 +263,7 @@ def add_teststep(test_runner, teststep_dict): try: test_runner.run_test(teststep_dict) except exceptions.MyBaseFailure as ex: - self.fail(repr(ex)) + self.fail(str(ex)) finally: if hasattr(test_runner.http_client_session, "meta_data"): self.meta_data = test_runner.http_client_session.meta_data