diff --git a/ate/utils.py b/ate/utils.py index 50a93ad6..a9685349 100644 --- a/ate/utils.py +++ b/ate/utils.py @@ -210,6 +210,8 @@ def match_expected(value, expected, comparator="eq"): assert value in expected elif comparator in ["regex"]: assert re.match(expected, value) + elif comparator in ["str_len", "string_length"]: + assert len(value) == int(expected) else: raise ParamsError("comparator not supported!") diff --git a/test/test_utils.py b/test/test_utils.py index 86aacec3..a607ce46 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -201,3 +201,6 @@ class TestUtils(ApiServerUnittest): with self.assertRaises(exception.ParamsError): utils.match_expected(1, 2, "not_supported_comparator") + + self.assertTrue(utils.match_expected("2017-06-29 17:29:58", 19, "str_len")) + self.assertTrue(utils.match_expected("2017-06-29 17:29:58", "19", "str_len"))