mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 04:19:28 +08:00
bugfix #31: comparator endswith
This commit is contained in:
@@ -204,7 +204,7 @@ def match_expected(value, expected, comparator="eq", check_item=""):
|
||||
elif comparator in ["startswith"]:
|
||||
assert str(value).startswith(str(expected))
|
||||
elif comparator in ["endswith"]:
|
||||
assert str(expected).startswith(str(value))
|
||||
assert str(value).endswith(str(expected))
|
||||
else:
|
||||
raise exception.ParamsError("comparator not supported!")
|
||||
|
||||
|
||||
@@ -191,6 +191,9 @@ class TestUtils(ApiServerUnittest):
|
||||
self.assertTrue(utils.match_expected("abc123", "ab", "startswith"))
|
||||
self.assertTrue(utils.match_expected("123abc", 12, "startswith"))
|
||||
self.assertTrue(utils.match_expected(12345, 123, "startswith"))
|
||||
self.assertTrue(utils.match_expected("abc123", 23, "endswith"))
|
||||
self.assertTrue(utils.match_expected("123abc", "abc", "endswith"))
|
||||
self.assertTrue(utils.match_expected(12345, 45, "endswith"))
|
||||
|
||||
self.assertTrue(utils.match_expected(None, None, "eq"))
|
||||
with self.assertRaises(exception.ValidationError):
|
||||
|
||||
Reference in New Issue
Block a user