diff --git a/httprunner/v3/response.py b/httprunner/v3/response.py index 8523a688..9c35ae4d 100644 --- a/httprunner/v3/response.py +++ b/httprunner/v3/response.py @@ -4,10 +4,10 @@ import jmespath import requests from loguru import logger -from httprunner.v3.exceptions import ParamsError, ValidationFailure -from httprunner.v3.parser import parse_data, parse_string_value +from httprunner.v3.exceptions import ValidationFailure +from httprunner.v3.parser import parse_data, parse_string_value, get_mapping_function from httprunner.v3.schema import VariablesMapping, Validators, FunctionsMapping -from httprunner.v3.validator import uniform_validator, AssertMethods +from httprunner.v3.validator import uniform_validator class ResponseObject(object): @@ -39,11 +39,7 @@ class ResponseObject(object): msg = f"assert {field} {assert_method} {expect_value}" - try: - assert_func = getattr(AssertMethods, assert_method) - except AttributeError: - raise ParamsError(f"Assert Method not supported: {assert_method}") - + assert_func = get_mapping_function(assert_method, functions_mapping) actual_value = parse_string_value(actual_value) # parse expected value with config/teststep/extracted variables expect_value = parse_data(expect_value, variables_mapping, functions_mapping) diff --git a/httprunner/v3/validator.py b/httprunner/v3/validator.py index cc0b39b9..c1278c2e 100644 --- a/httprunner/v3/validator.py +++ b/httprunner/v3/validator.py @@ -89,18 +89,3 @@ def uniform_validator(validator): "expect": expect_value, "assert": assert_method } - - -class AssertMethods(object): - - @staticmethod - def equals(actual_value, expect_value): - assert actual_value == expect_value - - @staticmethod - def less_than(actual_value, expect_value): - assert actual_value < expect_value - - @staticmethod - def greater_than(actual_value, expect_value): - assert actual_value > expect_value