mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
bugfix: TypeError in match_expected
This commit is contained in:
+2
-1
@@ -192,7 +192,8 @@ def match_expected(value, expected, comparator="eq", check_item=""):
|
|||||||
raise exception.ParamsError("comparator not supported!")
|
raise exception.ParamsError("comparator not supported!")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except AssertionError:
|
|
||||||
|
except (AssertionError, TypeError):
|
||||||
err_msg = "\n".join([
|
err_msg = "\n".join([
|
||||||
"check item name: %s;" % check_item,
|
"check item name: %s;" % check_item,
|
||||||
"check item value: %s (%s);" % (value, type(value).__name__),
|
"check item value: %s (%s);" % (value, type(value).__name__),
|
||||||
|
|||||||
@@ -196,6 +196,12 @@ class TestUtils(ApiServerUnittest):
|
|||||||
self.assertTrue(utils.match_expected("123abc", 12, "startswith"))
|
self.assertTrue(utils.match_expected("123abc", 12, "startswith"))
|
||||||
self.assertTrue(utils.match_expected(12345, 123, "startswith"))
|
self.assertTrue(utils.match_expected(12345, 123, "startswith"))
|
||||||
|
|
||||||
|
with self.assertRaises(exception.ValidationError):
|
||||||
|
utils.match_expected(None, 3, "len_eq")
|
||||||
|
|
||||||
|
with self.assertRaises(exception.ValidationError):
|
||||||
|
utils.match_expected("abc", None, "gt")
|
||||||
|
|
||||||
def test_deep_update_dict(self):
|
def test_deep_update_dict(self):
|
||||||
origin_dict = {'a': 1, 'b': {'c': 3, 'd': 4}, 'f': 6}
|
origin_dict = {'a': 1, 'b': {'c': 3, 'd': 4}, 'f': 6}
|
||||||
override_dict = {'a': 2, 'b': {'c': 33, 'e': 5}, 'g': 7}
|
override_dict = {'a': 2, 'b': {'c': 33, 'e': 5}, 'g': 7}
|
||||||
|
|||||||
Reference in New Issue
Block a user