From c9de8714857f649b27447aed2b3aed1b15f27f2f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 29 Jun 2017 17:27:23 +0800 Subject: [PATCH] bugfix: match_expected should raise ParamsError when comparator is not supported --- ate/utils.py | 2 ++ test/test_utils.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ate/utils.py b/ate/utils.py index b72cafaf..50a93ad6 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) + else: + raise ParamsError("comparator not supported!") return True except AssertionError: diff --git a/test/test_utils.py b/test/test_utils.py index 3a191e08..86aacec3 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -197,4 +197,7 @@ class TestUtils(ApiServerUnittest): self.assertTrue(utils.match_expected("3ab", "123abc456", "contained_by")) self.assertTrue(utils.match_expected("123abc456", "^123.*456$", "regex")) - self.assertFalse(utils.match_expected("123abc456", "^12b.*456$", "regex")) \ No newline at end of file + self.assertFalse(utils.match_expected("123abc456", "^12b.*456$", "regex")) + + with self.assertRaises(exception.ParamsError): + utils.match_expected(1, 2, "not_supported_comparator")