Fix __exit__ calls
The context manager protocol requires that __exit__ be called with three args: type, value, and traceback. In some places, we didn't include any args at all, leading to test failures during clean-up. Change-Id: I2998830e6eac685b1f753937d12cf5346a4eb081
This commit is contained in:
parent
3cb58f8efc
commit
6f813f6bfa
@ -177,7 +177,7 @@ class PatchPolicies(object):
|
||||
|
||||
def unpatch_cleanup(cls_self):
|
||||
if cls_self._policies_patched:
|
||||
self.__exit__()
|
||||
self.__exit__(None, None, None)
|
||||
cls_self._policies_patched = False
|
||||
|
||||
def setUp(cls_self):
|
||||
@ -204,7 +204,7 @@ class PatchPolicies(object):
|
||||
try:
|
||||
self._setup_rings()
|
||||
except: # noqa
|
||||
self.__exit__()
|
||||
self.__exit__(None, None, None)
|
||||
raise
|
||||
|
||||
def __exit__(self, *args):
|
||||
|
@ -58,11 +58,11 @@ class TestContainerDeleter(unittest.TestCase):
|
||||
patcher = mock.patch.object(container_deleter.time, 'time',
|
||||
side_effect=itertools.count())
|
||||
patcher.__enter__()
|
||||
self.addCleanup(patcher.__exit__)
|
||||
self.addCleanup(patcher.__exit__, None, None, None)
|
||||
|
||||
patcher = mock.patch.object(container_deleter, 'OBJECTS_PER_UPDATE', 5)
|
||||
patcher.__enter__()
|
||||
self.addCleanup(patcher.__exit__)
|
||||
self.addCleanup(patcher.__exit__, None, None, None)
|
||||
|
||||
def test_make_delete_jobs(self):
|
||||
ts = '1558463777.42739'
|
||||
|
Loading…
x
Reference in New Issue
Block a user