mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 14:59:38 +08:00
change: builtin comparator equal
This commit is contained in:
@@ -5,7 +5,7 @@ Built-in validate comparators.
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def equals(check_value, expect_value):
|
def equal(check_value, expect_value):
|
||||||
assert check_value == expect_value
|
assert check_value == expect_value
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ from httprunner.schema import VariablesMapping, Validators, FunctionsMapping
|
|||||||
def get_uniform_comparator(comparator: Text):
|
def get_uniform_comparator(comparator: Text):
|
||||||
""" convert comparator alias to uniform name
|
""" convert comparator alias to uniform name
|
||||||
"""
|
"""
|
||||||
if comparator in ["eq", "equals", "==", "is"]:
|
if comparator in ["eq", "equals", "equal"]:
|
||||||
return "equals"
|
return "equal"
|
||||||
elif comparator in ["lt", "less_than"]:
|
elif comparator in ["lt", "less_than"]:
|
||||||
return "less_than"
|
return "less_than"
|
||||||
elif comparator in ["le", "less_than_or_equals"]:
|
elif comparator in ["le", "less_than_or_equals"]:
|
||||||
@@ -62,8 +62,8 @@ def uniform_validator(validator):
|
|||||||
validator (dict): validator maybe in two formats:
|
validator (dict): validator maybe in two formats:
|
||||||
|
|
||||||
format1: this is kept for compatibility with the previous versions.
|
format1: this is kept for compatibility with the previous versions.
|
||||||
{"check": "status_code", "assert": "eq", "expect": 201}
|
{"check": "status_code", "comparator": "eq", "expect": 201}
|
||||||
{"check": "$resp_body_success", "assert": "eq", "expect": True}
|
{"check": "$resp_body_success", "comparator": "eq", "expect": True}
|
||||||
format2: recommended new version, {assert: [check_item, expected_value]}
|
format2: recommended new version, {assert: [check_item, expected_value]}
|
||||||
{'eq': ['status_code', 201]}
|
{'eq': ['status_code', 201]}
|
||||||
{'eq': ['$resp_body_success', True]}
|
{'eq': ['$resp_body_success', True]}
|
||||||
|
|||||||
Reference in New Issue
Block a user