diff --git a/httprunner/runner.py b/httprunner/runner.py index 5df077b5..d5f96a6d 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -267,7 +267,7 @@ class Runner(object): self.session_context.update_session_variables(extracted_variables_mapping) # validate - validators = test_dict.get("validate", []) + validators = test_dict.get("validate") or test_dict.get("validators") or [] try: self.session_context.validate(validators, resp_obj) except (exceptions.ParamsError, exceptions.ValidationFailure, exceptions.ExtractFailure): diff --git a/tests/httpbin/load_image.yml b/tests/httpbin/load_image.yml index 1243ef86..4ea6da75 100644 --- a/tests/httpbin/load_image.yml +++ b/tests/httpbin/load_image.yml @@ -7,7 +7,7 @@ request: url: /image/png method: GET - validators: + validate: - eq: ["status_code", 200] - test: @@ -15,7 +15,7 @@ request: url: /image/jpeg method: GET - validators: + validate: - eq: ["status_code", 200] - test: @@ -23,7 +23,7 @@ request: url: /image/webp method: GET - validators: + validate: - eq: ["status_code", 200] - test: @@ -31,6 +31,6 @@ request: url: /image/svg method: GET - validators: + validate: - eq: ["status_code", 200]