diff options
author | Tim Burke <tim.burke@gmail.com> | 2016-08-26 18:19:19 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2016-09-01 11:18:16 -0700 |
commit | 209677e6a8afeba048cca62b0383661052f7db2b (patch) | |
tree | 78ed46cda67363bc85d6de932158824aaf8c421b | |
parent | 20e0c515bf23841015102fb72d61ab18c826c036 (diff) | |
download | python-swiftclient-209677e6a8afeba048cca62b0383661052f7db2b.tar.gz |
Fix intermittent test failure
The mock needs to be initialized before calling main, or we get a race
to create it between all the uu_threads
Change-Id: If7649da13ed9276d7f0e005e999770e09c022a3f
-rw-r--r-- | tests/unit/test_shell.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py index c0fcc41..6c4ebed 100644 --- a/tests/unit/test_shell.py +++ b/tests/unit/test_shell.py @@ -1328,8 +1328,8 @@ class TestShell(unittest.TestCase): fresh_metadata=False, headers={'X-Object-Meta-Color': 'Blue'}, response_dict={}) ] - for call in calls: - self.assertIn(call, connection.return_value.copy_object.mock_calls) + connection.return_value.copy_object.assert_has_calls( + calls, any_order=True) self.assertEqual(len(connection.return_value.copy_object.mock_calls), len(calls)) @@ -1337,6 +1337,7 @@ class TestShell(unittest.TestCase): def test_copy_two_objects_destination(self, connection): argv = ["", "copy", "container", "object", "object2", "--meta", "Color:Blue", "--destination", "/c"] + connection.return_value.copy_object.return_value = None swiftclient.shell.main(argv) calls = [ mock.call( @@ -1348,7 +1349,10 @@ class TestShell(unittest.TestCase): fresh_metadata=False, headers={'X-Object-Meta-Color': 'Blue'}, response_dict={}) ] - connection.return_value.copy_object.assert_has_calls(calls) + connection.return_value.copy_object.assert_has_calls( + calls, any_order=True) + self.assertEqual(len(connection.return_value.copy_object.mock_calls), + len(calls)) @mock.patch('swiftclient.service.Connection') def test_copy_two_objects_bad_destination(self, connection): |