From 424d48692d6b0c954504b8738309f201be1c4c05 Mon Sep 17 00:00:00 2001 From: 01382037 Date: Wed, 11 Nov 2020 16:09:50 +0800 Subject: [PATCH 1/2] fix: comparator contained_by should assert the type of expect_vaule. --- httprunner/builtin/comparators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httprunner/builtin/comparators.py b/httprunner/builtin/comparators.py index 897112ee..58f9f3c9 100644 --- a/httprunner/builtin/comparators.py +++ b/httprunner/builtin/comparators.py @@ -92,7 +92,7 @@ def contains(check_value: Any, expect_value: Any, message: Text = ""): def contained_by(check_value: Any, expect_value: Any, message: Text = ""): assert isinstance( - check_value, (list, tuple, dict, str, bytes) + expect_value, (list, tuple, dict, str, bytes) ), "expect_value should be list/tuple/dict/str/bytes type" assert check_value in expect_value, message From 476578f14a6e0f53c12517d84401d393c3992800 Mon Sep 17 00:00:00 2001 From: 01382037 Date: Wed, 11 Nov 2020 16:16:52 +0800 Subject: [PATCH 2/2] tests: add test --- tests/utils_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/utils_test.py b/tests/utils_test.py index b03d7162..df51c2c0 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -49,6 +49,7 @@ class TestUtils(unittest.TestCase): functions_mapping["contains"](["1", "2"], "1") functions_mapping["contains"]({"a": 1, "b": 2}, "a") functions_mapping["contained_by"]("3ab", "123abc456") + functions_mapping["contained_by"](0, [0, 200]) functions_mapping["regex_match"]("123abc456", "^123\w+456$") with self.assertRaises(AssertionError):