fix #942: type_match None

This commit is contained in:
debugtalk
2020-06-21 15:04:04 +08:00
parent 6710eba1fc
commit 2b75d78df0
5 changed files with 19 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
# Release History
## 3.1.1 (2020-06-21)
**Fixed**
- fix #942: type_match None
## 3.1.0 (2020-06-21)
**Added**

View File

@@ -48,6 +48,9 @@ teststeps:
validate:
- eq: ["status_code", 200]
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar21."]
- type_match: ["body.json", None]
- type_match: ["body.json", NoneType]
- type_match: ["body.json", null]
-
name: post form data
variables:

View File

@@ -57,6 +57,9 @@ class TestCaseRequestWithFunctions(HttpRunner):
"body.data",
"This is expected to be sent back as part of response body: bar12-$expect_foo2-bar21.",
)
.assert_type_match("body.json", "None")
.assert_type_match("body.json", "NoneType")
.assert_type_match("body.json", None)
),
Step(
RunRequest("post form data")

View File

@@ -80,7 +80,10 @@ def type_match(check_value, expect_value):
else:
raise ValueError(name)
assert isinstance(check_value, get_type(expect_value))
if expect_value in ["None", "NoneType", None]:
assert check_value is None
else:
assert type(check_value) == get_type(expect_value)
def regex_match(check_value, expect_value):

View File

@@ -69,6 +69,9 @@ class TestUtils(unittest.TestCase):
functions_mapping["type_match"]([1], "list")
functions_mapping["type_match"]({}, "dict")
functions_mapping["type_match"]({"a": 1}, "dict")
functions_mapping["type_match"](None, "None")
functions_mapping["type_match"](None, "NoneType")
functions_mapping["type_match"](None, None)
def test_lower_dict_keys(self):
request_dict = {