diff --git a/ate/utils.py b/ate/utils.py index 093df3a8..96d7dfbf 100644 --- a/ate/utils.py +++ b/ate/utils.py @@ -204,7 +204,7 @@ def match_expected(value, expected, comparator="eq", check_item=""): elif comparator in ["startswith"]: assert str(value).startswith(str(expected)) elif comparator in ["endswith"]: - assert str(expected).startswith(str(value)) + assert str(value).endswith(str(expected)) else: raise exception.ParamsError("comparator not supported!") diff --git a/tests/test_utils.py b/tests/test_utils.py index 5d7f9b75..619bebf3 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -191,6 +191,9 @@ class TestUtils(ApiServerUnittest): self.assertTrue(utils.match_expected("abc123", "ab", "startswith")) self.assertTrue(utils.match_expected("123abc", 12, "startswith")) self.assertTrue(utils.match_expected(12345, 123, "startswith")) + self.assertTrue(utils.match_expected("abc123", 23, "endswith")) + self.assertTrue(utils.match_expected("123abc", "abc", "endswith")) + self.assertTrue(utils.match_expected(12345, 45, "endswith")) self.assertTrue(utils.match_expected(None, None, "eq")) with self.assertRaises(exception.ValidationError):