From a656fd764b0a608caaf198bfa9685a09a7eaca16 Mon Sep 17 00:00:00 2001 From: Vincent Danno Date: Wed, 26 May 2021 13:08:55 +0200 Subject: Drop six python 2 was dropped [1] so we don't need six anymore [1]: https://gerrit.opnfv.org/gerrit/c/functest-xtesting/+/68262 Signed-off-by: Vincent Danno Change-Id: I840211990b76f77a46e9e737fc4a4c857b57c0b2 --- xtesting/tests/unit/core/test_feature.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'xtesting/tests/unit/core/test_feature.py') diff --git a/xtesting/tests/unit/core/test_feature.py b/xtesting/tests/unit/core/test_feature.py index ab483b27..b36fa367 100644 --- a/xtesting/tests/unit/core/test_feature.py +++ b/xtesting/tests/unit/core/test_feature.py @@ -11,12 +11,12 @@ import os +from io import BytesIO import logging import subprocess import unittest import mock -import six from xtesting.core import feature from xtesting.core import testcase @@ -73,7 +73,7 @@ class FeatureTesting(FeatureTestingBase): # logging must be disabled else it calls time.time() # what will break these unit tests. logging.disable(logging.CRITICAL) - with mock.patch('six.moves.builtins.open'): + with mock.patch('builtins.open'): self.feature = FakeTestCase( project_name=self._project_name, case_name=self._case_name) @@ -95,7 +95,7 @@ class BashFeatureTesting(FeatureTestingBase): # logging must be disabled else it calls time.time() # what will break these unit tests. logging.disable(logging.CRITICAL) - with mock.patch('six.moves.builtins.open'): + with mock.patch('builtins.open'): self.feature = feature.BashFeature( project_name=self._project_name, case_name=self._case_name) @@ -109,7 +109,7 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('subprocess.Popen', side_effect=subprocess.CalledProcessError(0, '', '')) def test_run_ko1(self, *args): - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run(testcase.TestCase.EX_RUN_ERROR) mopen.assert_called_once_with(self._output_file, "w") args[0].assert_called_once_with( @@ -119,12 +119,12 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('os.path.isdir', return_value=True) @mock.patch('subprocess.Popen') def test_run_ko2(self, *args): - stream = six.BytesIO() + stream = BytesIO() stream.write(b"foo") stream.seek(0) attrs = {'return_value.stdout': stream, 'return_value.returncode': 1} args[0].configure_mock(**attrs) - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run(testcase.TestCase.EX_RUN_ERROR) self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls) self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls) @@ -135,12 +135,12 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('os.path.isdir', return_value=True) @mock.patch('subprocess.Popen') def test_run1(self, *args): - stream = six.BytesIO() + stream = BytesIO() stream.write(b"foo") stream.seek(0) attrs = {'return_value.stdout': stream, 'return_value.returncode': 0} args[0].configure_mock(**attrs) - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run(testcase.TestCase.EX_OK) self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls) self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls) @@ -151,12 +151,12 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('os.path.isdir', return_value=True) @mock.patch('subprocess.Popen') def test_run2(self, *args): - stream = six.BytesIO() + stream = BytesIO() stream.write(b"foo") stream.seek(0) attrs = {'return_value.stdout': stream, 'return_value.returncode': 0} args[0].configure_mock(**attrs) - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run_console(True, testcase.TestCase.EX_OK) self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls) self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls) @@ -167,12 +167,12 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('os.path.isdir', return_value=True) @mock.patch('subprocess.Popen') def test_run3(self, *args): - stream = six.BytesIO() + stream = BytesIO() stream.write(b"foo") stream.seek(0) attrs = {'return_value.stdout': stream, 'return_value.returncode': 0} args[0].configure_mock(**attrs) - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run_console(False, testcase.TestCase.EX_OK) self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls) self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls) @@ -184,12 +184,12 @@ class BashFeatureTesting(FeatureTestingBase): @mock.patch('os.path.isdir', return_value=False) @mock.patch('subprocess.Popen') def test_run4(self, *args): - stream = six.BytesIO() + stream = BytesIO() stream.write(b"foo") stream.seek(0) attrs = {'return_value.stdout': stream, 'return_value.returncode': 0} args[0].configure_mock(**attrs) - with mock.patch('six.moves.builtins.open', mock.mock_open()) as mopen: + with mock.patch('builtins.open', mock.mock_open()) as mopen: self._test_run_console(False, testcase.TestCase.EX_OK) self.assertIn(mock.call(self._output_file, 'w'), mopen.mock_calls) self.assertIn(mock.call(self._output_file, 'r'), mopen.mock_calls) -- cgit 1.2.3-korg