mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
match_expected: add comparator str_len/string_length
This commit is contained in:
@@ -210,6 +210,8 @@ def match_expected(value, expected, comparator="eq"):
|
||||
assert value in expected
|
||||
elif comparator in ["regex"]:
|
||||
assert re.match(expected, value)
|
||||
elif comparator in ["str_len", "string_length"]:
|
||||
assert len(value) == int(expected)
|
||||
else:
|
||||
raise ParamsError("comparator not supported!")
|
||||
|
||||
|
||||
@@ -201,3 +201,6 @@ class TestUtils(ApiServerUnittest):
|
||||
|
||||
with self.assertRaises(exception.ParamsError):
|
||||
utils.match_expected(1, 2, "not_supported_comparator")
|
||||
|
||||
self.assertTrue(utils.match_expected("2017-06-29 17:29:58", 19, "str_len"))
|
||||
self.assertTrue(utils.match_expected("2017-06-29 17:29:58", "19", "str_len"))
|
||||
|
||||
Reference in New Issue
Block a user