- The mock library provides a 'mock_open' function to mock the 'open'
builtin's context manager. We should have been using this but were
not.
- We were mocking another context manager in a fairly strange way. This
seems to be causing issues, possibly down to race. We shouldn't do
that.
Reviewed: https:/ /review. openstack. org/561190 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=5c98984bb6e 7912a9074a71514 8db94ce06db444
Committed: https:/
Submitter: Zuul
Branch: master
commit 5c98984bb6e7912 a9074a715148db9 4ce06db444
Author: Stephen Finucane <email address hidden>
Date: Fri Apr 13 11:29:55 2018 +0100
tests: Fix how context managers are mocked
Two issues here:
- The mock library provides a 'mock_open' function to mock the 'open'
builtin's context manager. We should have been using this but were
not.
- We were mocking another context manager in a fairly strange way. This
seems to be causing issues, possibly down to race. We shouldn't do
that.
Fix both issues.
Change-Id: I289b56ae3f9ccd 16d72b2ca317e68 e6c18b8b313
Fixes-Bug: #1763535