Initialize delete_object mock *before* creating all the threads

Previously, we'd occasionally get spurious failures like

    FAIL: test_delete_account (tests.unit.test_shell.TestShell)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File ".../mock/mock.py", line 1721, in _inner
        return f(*args, **kw)
      File ".../mock/mock.py", line 1305, in patched
        return func(*args, **keywargs)
      File ".../tests/unit/test_shell.py", line 788, in test_delete_account
        response_dict={})], any_order=True)
      File ".../mock/mock.py", line 983, in assert_has_calls
        ), cause)
      File ".../six.py", line 718, in raise_from
        raise value
    AssertionError: (call(u'container', u'object', query_string=None,
                          response_dict={}),)
    not all found in call list

Related-Bug: #1539536
Related-Bug: #1480223
Change-Id: I810894545ca74d3b2f2dbde2d0388eb69c2ba710
This commit is contained in:
Tim Burke 2016-03-17 15:32:10 -07:00
parent 985c038209
commit d2bd2f0859

@ -778,6 +778,7 @@ class TestShell(unittest.TestCase):
connection.return_value.attempts = 0
argv = ["", "delete", "--all"]
connection.return_value.head_object.return_value = {}
connection.return_value.delete_object.return_value = None
swiftclient.shell.main(argv)
connection.return_value.delete_object.assert_has_calls([
mock.call('container', 'object', query_string=None,