bugfix #31: comparator endswith

This commit is contained in:
httprunner
2017-08-22 17:51:31 +08:00
parent 7b44fd39d5
commit 2e9da796ef
2 changed files with 4 additions and 1 deletions

View File

@@ -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!")

View File

@@ -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):