Replaces reload() and __builtin__ for Python 3.x
Uses "six.moves.reload_module" and "six.moves.builtins"
This commit is contained in:
@@ -21,6 +21,7 @@ import sys
|
||||
import unittest
|
||||
|
||||
from oslo.config import cfg
|
||||
from six import moves
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
@@ -37,7 +38,7 @@ class ExtendVolumesPluginTests(unittest.TestCase):
|
||||
self._extend_volumes = extendvolumes.ExtendVolumesPlugin()
|
||||
|
||||
def tearDown(self):
|
||||
reload(sys)
|
||||
moves.reload_module(sys)
|
||||
|
||||
@mock.patch('cloudbaseinit.plugins.windows.extendvolumes'
|
||||
'.ExtendVolumesPlugin._get_volume_index')
|
||||
|
@@ -18,6 +18,7 @@ import uuid
|
||||
import unittest
|
||||
|
||||
from oslo.config import cfg
|
||||
from six import moves
|
||||
|
||||
from cloudbaseinit.plugins.windows import userdatautils
|
||||
from cloudbaseinit.tests.metadata import fake_json_response
|
||||
@@ -32,7 +33,7 @@ class UserDataUtilsTest(unittest.TestCase):
|
||||
'2013-04-04')
|
||||
|
||||
def tearDown(self):
|
||||
reload(uuid)
|
||||
moves.reload_module(uuid)
|
||||
|
||||
@mock.patch('re.search')
|
||||
@mock.patch('tempfile.gettempdir')
|
||||
|
@@ -19,6 +19,8 @@ import mock
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from six import moves
|
||||
|
||||
from cloudbaseinit.plugins import base
|
||||
from cloudbaseinit.plugins import constants
|
||||
|
||||
@@ -41,7 +43,7 @@ class ConfigWinRMCertificateAuthPluginTests(unittest.TestCase):
|
||||
self._certif_auth = self.winrmcert.ConfigWinRMCertificateAuthPlugin()
|
||||
|
||||
def tearDown(self):
|
||||
reload(sys)
|
||||
moves.reload_module(sys)
|
||||
|
||||
def _test_get_credentials(self, fake_user, fake_password):
|
||||
mock_shared_data = mock.MagicMock()
|
||||
|
@@ -45,7 +45,7 @@ class HeatUserDataHandlerTests(unittest.TestCase):
|
||||
mock_execute_user_data_script, filename):
|
||||
mock_part = mock.MagicMock()
|
||||
mock_part.get_filename.return_value = filename
|
||||
with mock.patch('__builtin__.open', mock.mock_open(),
|
||||
with mock.patch('six.moves.builtins.open', mock.mock_open(),
|
||||
create=True) as handle:
|
||||
response = self._heat.process(mock_part)
|
||||
handle().write.assert_called_once_with(mock_part.get_payload())
|
||||
|
@@ -15,10 +15,11 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from oslo.config import cfg
|
||||
from six import moves
|
||||
|
||||
from cloudbaseinit import init
|
||||
from cloudbaseinit.plugins import base
|
||||
@@ -44,8 +45,8 @@ class InitManagerTest(unittest.TestCase):
|
||||
self._init = init.InitManager()
|
||||
|
||||
def tearDown(self):
|
||||
reload(sys)
|
||||
reload(init)
|
||||
moves.reload_module(sys)
|
||||
moves.reload_module(init)
|
||||
|
||||
def _test_get_plugin_section(self, instance_id):
|
||||
response = self._init._get_plugins_section(instance_id=instance_id)
|
||||
|
Reference in New Issue
Block a user