aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests')
-rw-r--r--functest/tests/unit/odl/test_odl.py2
-rw-r--r--functest/tests/unit/openstack/tempest/test_tempest.py14
-rw-r--r--functest/tests/unit/openstack/vmtp/test_vmtp.py1
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py33
4 files changed, 24 insertions, 26 deletions
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 1b2e10b07..24ac04591 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -541,7 +541,7 @@ class ODLArgParserTesting(ODLTesting):
def setUp(self):
self.parser = odl.ODLParser()
- super(ODLArgParserTesting, self).setUp()
+ super().setUp()
def test_default(self):
self.assertEqual(self.parser.parse_args(), self.defaultargs)
diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py
index 6ff404a13..e27b52ef4 100644
--- a/functest/tests/unit/openstack/tempest/test_tempest.py
+++ b/functest/tests/unit/openstack/tempest/test_tempest.py
@@ -269,10 +269,9 @@ class OSTempestTesting(unittest.TestCase):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
'tempest.subprocess.Popen') as mock_popen:
- mock_stdout = mock.Mock()
- attrs = {'stdout.readline.return_value': b'test_deploy_id'}
- mock_stdout.configure_mock(**attrs)
- mock_popen.return_value = mock_stdout
+ attrs = {'return_value.__enter__.return_value.'
+ 'stdout.readline.return_value': b'test_deploy_id'}
+ mock_popen.configure_mock(**attrs)
self.assertEqual(self.tempestcommon.get_verifier_id(),
'test_deploy_id')
@@ -281,10 +280,9 @@ class OSTempestTesting(unittest.TestCase):
setattr(config.CONF, 'tempest_verifier_name', 'test_deploy_name')
with mock.patch('functest.opnfv_tests.openstack.tempest.'
'tempest.subprocess.Popen') as mock_popen:
- mock_stdout = mock.Mock()
- attrs = {'stdout.readline.return_value': b'test_deploy_id'}
- mock_stdout.configure_mock(**attrs)
- mock_popen.return_value = mock_stdout
+ attrs = {'return_value.__enter__.return_value.'
+ 'stdout.readline.return_value': b'test_deploy_id'}
+ mock_popen.configure_mock(**attrs)
self.assertEqual(rally.RallyBase.get_verifier_deployment_id(),
'test_deploy_id')
diff --git a/functest/tests/unit/openstack/vmtp/test_vmtp.py b/functest/tests/unit/openstack/vmtp/test_vmtp.py
index fcbb0c46b..c1ad30afd 100644
--- a/functest/tests/unit/openstack/vmtp/test_vmtp.py
+++ b/functest/tests/unit/openstack/vmtp/test_vmtp.py
@@ -74,7 +74,6 @@ class VmtpTesting(unittest.TestCase):
@mock.patch('six.moves.builtins.open')
def test_generate_keys2(self, *args):
- # pylint: disable=bad-continuation
with mock.patch.object(
self.testcase.cloud, "create_keypair",
side_effect=shade.OpenStackCloudException(None)) as mock_obj, \
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index b22670f76..1fab8f175 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -100,10 +100,10 @@ class FunctestUtilsTesting(unittest.TestCase):
mock.mock_open()) as mopen:
stream = six.BytesIO()
stream.write(self.cmd_readline().encode("utf-8"))
- mock_obj2 = mock.Mock()
- attrs = {'stdout': stream, 'wait.return_value': 1}
- mock_obj2.configure_mock(**attrs)
- mock_subproc_open.return_value = mock_obj2
+ attrs = {
+ 'return_value.__enter__.return_value.stdout': stream,
+ 'return_value.__enter__.return_value.wait.return_value': 1}
+ mock_subproc_open.configure_mock(**attrs)
resp = functest_utils.execute_command(
self.cmd, info=True, error_msg=self.error_msg, verbose=True,
output_file=self.output_file)
@@ -121,10 +121,10 @@ class FunctestUtilsTesting(unittest.TestCase):
mock.mock_open()) as mopen:
stream = six.BytesIO()
stream.write(self.cmd_readline().encode("utf-8"))
- mock_obj2 = mock.Mock()
- attrs = {'stdout': stream, 'wait.return_value': 0}
- mock_obj2.configure_mock(**attrs)
- mock_subproc_open.return_value = mock_obj2
+ attrs = {
+ 'return_value.__enter__.return_value.stdout': stream,
+ 'return_value.__enter__.return_value.wait.return_value': 0}
+ mock_subproc_open.configure_mock(**attrs)
resp = functest_utils.execute_command(
self.cmd, info=True, error_msg=self.error_msg, verbose=True,
output_file=self.output_file)
@@ -140,10 +140,10 @@ class FunctestUtilsTesting(unittest.TestCase):
as mock_subproc_open:
stream = six.BytesIO()
stream.write(self.cmd_readline().encode("utf-8"))
- mock_obj2 = mock.Mock()
- attrs = {'stdout': stream, 'wait.return_value': 0}
- mock_obj2.configure_mock(**attrs)
- mock_subproc_open.return_value = mock_obj2
+ attrs = {
+ 'return_value.__enter__.return_value.stdout': stream,
+ 'return_value.__enter__.return_value.wait.return_value': 0}
+ mock_subproc_open.configure_mock(**attrs)
resp = functest_utils.execute_command(
self.cmd, info=False, error_msg="", verbose=False,
output_file=None)
@@ -154,12 +154,13 @@ class FunctestUtilsTesting(unittest.TestCase):
# pylint: disable=unused-argument
with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
as mock_subproc_open:
+ attrs = {}
stream = six.BytesIO()
stream.write(self.cmd_readline().encode("utf-8"))
- mock_obj2 = mock.Mock()
- attrs = {'stdout': stream, 'wait.return_value': 1}
- mock_obj2.configure_mock(**attrs)
- mock_subproc_open.return_value = mock_obj2
+ attrs = {
+ 'return_value.__enter__.return_value.stdout': stream,
+ 'return_value.__enter__.return_value.wait.return_value': 1}
+ mock_subproc_open.configure_mock(**attrs)
resp = functest_utils.execute_command(
self.cmd, info=False, error_msg="", verbose=False,
output_file=None)