From d28ccb37ff5d9e310c4e6d4409f9d642423dd260 Mon Sep 17 00:00:00 2001 From: "Chaozhe.Chen" Date: Thu, 18 Feb 2016 15:26:16 +0800 Subject: [PATCH] Test: use assert_has_calls() instead Some of the assertions in glanceclient test are sequential, we should better use assert_has_calls() instead of assert_any_call(). And assert_has_calls() provides more clear messages in case of failure. Change-Id: Ie45e7c56b1c859916a1f31636c639422f1ffef28 --- glanceclient/tests/unit/test_shell.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py index 7b3e79ed..2a33dc00 100644 --- a/glanceclient/tests/unit/test_shell.py +++ b/glanceclient/tests/unit/test_shell.py @@ -686,9 +686,12 @@ class ShellCacheSchemaTest(testutils.TestCase): self.shell._cache_schemas(self._make_args(options), client, home_dir=self.cache_dir) - os.path.exists.assert_any_call(self.prefix_path) - os.path.exists.assert_any_call(self.cache_files[0]) - os.path.exists.assert_any_call(self.cache_files[1]) + exists_mock.assert_has_calls([ + mock.call(self.prefix_path), + mock.call(self.cache_files[0]), + mock.call(self.cache_files[1]), + mock.call(self.cache_files[2]) + ]) self.assertEqual(4, exists_mock.call_count) self.assertEqual(0, open.mock_calls.__len__())