mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-18 01:07:36 +08:00
bugfix #100: Null value can only be compared with comparator: eq/equals/==
This commit is contained in:
@@ -218,10 +218,11 @@ class Context(object):
|
|||||||
check_value = validator_dict["check_value"]
|
check_value = validator_dict["check_value"]
|
||||||
expect_value = validator_dict["expect"]
|
expect_value = validator_dict["expect"]
|
||||||
|
|
||||||
try:
|
if (check_value is None or expect_value is None) \
|
||||||
if check_value is None or expect_value is None:
|
and comparator not in ["is", "eq", "equals", "=="]:
|
||||||
assert comparator in ["is", "eq", "equals", "=="]
|
raise exception.ParamsError("Null value can only be compared with comparator: eq/equals/==")
|
||||||
|
|
||||||
|
try:
|
||||||
validate_func(validator_dict["check_value"], validator_dict["expect"])
|
validate_func(validator_dict["check_value"], validator_dict["expect"])
|
||||||
except (AssertionError, TypeError):
|
except (AssertionError, TypeError):
|
||||||
err_msg = "\n" + "\n".join([
|
err_msg = "\n" + "\n".join([
|
||||||
|
|||||||
@@ -802,6 +802,8 @@ class TestcaseParser(object):
|
|||||||
"body": {"name": "user", "password": "123456"}
|
"body": {"name": "user", "password": "123456"}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
if content is None:
|
||||||
|
return None
|
||||||
|
|
||||||
if isinstance(content, (list, tuple)):
|
if isinstance(content, (list, tuple)):
|
||||||
return [
|
return [
|
||||||
@@ -822,7 +824,7 @@ class TestcaseParser(object):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
# content is in string format here
|
# content is in string format here
|
||||||
content = "" if content is None else content.strip()
|
content = content.strip()
|
||||||
|
|
||||||
# replace functions with evaluated value
|
# replace functions with evaluated value
|
||||||
# Notice: _eval_content_functions must be called before _eval_content_variables
|
# Notice: _eval_content_functions must be called before _eval_content_variables
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ def query_json(json_content, query, delimiter='.'):
|
|||||||
def get_uniform_comparator(comparator):
|
def get_uniform_comparator(comparator):
|
||||||
""" convert comparator alias to uniform name
|
""" convert comparator alias to uniform name
|
||||||
"""
|
"""
|
||||||
if comparator in ["eq", "equals", "=="]:
|
if comparator in ["eq", "equals", "==", "is"]:
|
||||||
return "equals"
|
return "equals"
|
||||||
elif comparator in ["lt", "less_than"]:
|
elif comparator in ["lt", "less_than"]:
|
||||||
return "less_than"
|
return "less_than"
|
||||||
|
|||||||
Reference in New Issue
Block a user