From 3466bcbf9b6359ebf25b69564f5ce299b9691023 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 11 Apr 2019 12:30:03 +0800 Subject: [PATCH] support both "validate" and "validators" --- httprunner/runner.py | 2 +- tests/httpbin/load_image.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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]