]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
VMware: Remove global patching of open
authorVipin Balachandran <vbala@vmware.com>
Fri, 4 Sep 2015 08:17:34 +0000 (13:47 +0530)
committerVipin Balachandran <vbala@vmware.com>
Fri, 4 Sep 2015 11:45:01 +0000 (17:15 +0530)
commit05c2ba2ebc6041c2e3d3481c1898a90517d01e5b
tree180d88aa1c773fdfb01bb454a30680303d4028a9
parent6dba657a2987955248e781ae9df28351ef10420d
VMware: Remove global patching of open

Commit 212aff327a36f925be3be69b9b54b946dbdd5c2a replaced
'cinder.openstack.common.fileutils.file_open' with 'open'
from builtins. It also updated unit tests to patch 'six.
moves.builtins.open' instead of 'cinder.openstack.common.
fileutils.file_open'. This resulted in intermittent failure
of test 'test_create_backing_from_stream_optimized_file'
in VMwareVcVmdkDriverTestCase. The failure happens because
the test patches 'open' from builtins and tests code which
throws an exception in a 'with open(...)' block. This
exception is handled in excutils.save_and_reraise_exception
which uses 'with open(...)' and the exception handling
fails due to the global patching of 'open'.

This patch replaces the global patching of builtins 'open'
with a patch decorator which binds 'open' to the namespace
of the code under testing.

Closes-bug: #1488690
Change-Id: Ib0f47b8fcbc54a9111c1bdff6d4b6fa7568518ca
cinder/tests/unit/test_vmware_vmdk.py