summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorMoshe Levi <moshele@mellanox.com>2016-02-17 14:08:42 +0200
committerMoshe Levi <moshele@mellanox.com>2016-02-17 14:08:52 +0200
commit52fc4f891f59838ed5655f596ba9df1a4f2404ec (patch)
treebd3d4547e5ca58c8a6dd8fdd8552f390aa48cc1e /ironic_python_agent/tests/unit/test_utils.py
parent559b25f56ea6667250a20c8fc2780773a3e373c7 (diff)
downloadironic-python-agent-52fc4f891f59838ed5655f596ba9df1a4f2404ec.tar.gz
Update unit tests to use six.moves.builtins.open
Change-Id: I724a42d22d4c9011feb8aa09726e5186686f3729
Diffstat (limited to 'ironic_python_agent/tests/unit/test_utils.py')
-rw-r--r--ironic_python_agent/tests/unit/test_utils.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py
index 694fbb93..fd1cd5d6 100644
--- a/ironic_python_agent/tests/unit/test_utils.py
+++ b/ironic_python_agent/tests/unit/test_utils.py
@@ -23,18 +23,11 @@ import testtools
import mock
from oslo_concurrency import processutils
from oslotest import base as test_base
-import six
from ironic_python_agent import errors
from ironic_python_agent import utils
-if six.PY2:
- OPEN_FUNCTION_NAME = '__builtin__.open'
-else:
- OPEN_FUNCTION_NAME = 'builtins.open'
-
-
class ExecuteTestCase(testtools.TestCase):
"""This class is a copy of the same class in openstack/ironic."""
@@ -135,13 +128,13 @@ grep foo
class GetAgentParamsTestCase(test_base.BaseTestCase):
@mock.patch('oslo_log.log.getLogger')
- @mock.patch(OPEN_FUNCTION_NAME)
+ @mock.patch('six.moves.builtins.open')
def test__read_params_from_file_fail(self, logger_mock, open_mock):
open_mock.side_effect = Exception
params = utils._read_params_from_file('file-path')
self.assertEqual({}, params)
- @mock.patch(OPEN_FUNCTION_NAME)
+ @mock.patch('six.moves.builtins.open')
def test__read_params_from_file(self, open_mock):
kernel_line = 'api-url=http://localhost:9999 baz foo=bar\n'
open_mock.return_value.__enter__ = lambda s: s
@@ -201,7 +194,7 @@ class GetAgentParamsTestCase(test_base.BaseTestCase):
self.assertEqual(expected_params, returned_params)
self.assertEqual(0, set_cache_mock.call_count)
- @mock.patch(OPEN_FUNCTION_NAME)
+ @mock.patch('six.moves.builtins.open')
@mock.patch.object(glob, 'glob')
def test__get_vmedia_device(self, glob_mock, open_mock):