mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-13 00:11:28 +08:00
bugfix: match_expected should raise ParamsError when comparator is not supported
This commit is contained in:
@@ -210,6 +210,8 @@ def match_expected(value, expected, comparator="eq"):
|
|||||||
assert value in expected
|
assert value in expected
|
||||||
elif comparator in ["regex"]:
|
elif comparator in ["regex"]:
|
||||||
assert re.match(expected, value)
|
assert re.match(expected, value)
|
||||||
|
else:
|
||||||
|
raise ParamsError("comparator not supported!")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
|
|||||||
@@ -197,4 +197,7 @@ class TestUtils(ApiServerUnittest):
|
|||||||
self.assertTrue(utils.match_expected("3ab", "123abc456", "contained_by"))
|
self.assertTrue(utils.match_expected("3ab", "123abc456", "contained_by"))
|
||||||
|
|
||||||
self.assertTrue(utils.match_expected("123abc456", "^123.*456$", "regex"))
|
self.assertTrue(utils.match_expected("123abc456", "^123.*456$", "regex"))
|
||||||
self.assertFalse(utils.match_expected("123abc456", "^12b.*456$", "regex"))
|
self.assertFalse(utils.match_expected("123abc456", "^12b.*456$", "regex"))
|
||||||
|
|
||||||
|
with self.assertRaises(exception.ParamsError):
|
||||||
|
utils.match_expected(1, 2, "not_supported_comparator")
|
||||||
|
|||||||
Reference in New Issue
Block a user