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_unit.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'xtesting/tests/unit/core/test_unit.py') diff --git a/xtesting/tests/unit/core/test_unit.py b/xtesting/tests/unit/core/test_unit.py index 3be41442..86577713 100644 --- a/xtesting/tests/unit/core/test_unit.py +++ b/xtesting/tests/unit/core/test_unit.py @@ -7,12 +7,12 @@ # pylint: disable=missing-docstring +import io import logging import subprocess import unittest import mock -import six from xtesting.core import unit from xtesting.core import testcase @@ -26,7 +26,7 @@ class SuiteTesting(unittest.TestCase): @mock.patch('subprocess.Popen', side_effect=Exception) def test_generate_stats_ko(self, *args): - stream = six.StringIO() + stream = io.StringIO() with self.assertRaises(Exception): self.psrunner.generate_stats(stream) args[0].assert_called_once_with( @@ -36,17 +36,17 @@ class SuiteTesting(unittest.TestCase): return_value=mock.Mock( communicate=mock.Mock(return_value=(b"foo", b"bar")))) def test_generate_stats_ok(self, *args): - stream = six.StringIO() + stream = io.StringIO() self.psrunner.generate_stats(stream) args[0].assert_called_once_with( ['subunit-stats'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) - @mock.patch('six.moves.builtins.open', mock.mock_open()) + @mock.patch('builtins.open', mock.mock_open()) @mock.patch('subprocess.Popen', side_effect=Exception) def test_generate_xunit_ko(self, *args): - stream = six.StringIO() + stream = io.StringIO() with self.assertRaises(Exception), \ - mock.patch('six.moves.builtins.open', + mock.patch('builtins.open', mock.mock_open()) as mock_open: self.psrunner.generate_xunit(stream) args[0].assert_called_once_with( @@ -59,8 +59,8 @@ class SuiteTesting(unittest.TestCase): return_value=mock.Mock( communicate=mock.Mock(return_value=(b"foo", b"bar")))) def test_generate_xunit_ok(self, *args): - stream = six.BytesIO() - with mock.patch('six.moves.builtins.open', + stream = io.BytesIO() + with mock.patch('builtins.open', mock.mock_open()) as mock_open: self.psrunner.generate_xunit(stream) args[0].assert_called_once_with( @@ -93,7 +93,7 @@ class SuiteTesting(unittest.TestCase): @mock.patch('subunit.run.SubunitTestRunner.run') def _test_run(self, mock_result, status, result, *args): args[0].return_value = mock_result - with mock.patch('six.moves.builtins.open', mock.mock_open()) as m_open: + with mock.patch('builtins.open', mock.mock_open()) as m_open: self.assertEqual(self.psrunner.run(), status) m_open.assert_called_once_with( '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb') @@ -112,7 +112,7 @@ class SuiteTesting(unittest.TestCase): @mock.patch('subunit.run.SubunitTestRunner.run') def _test_run_name(self, name, mock_result, status, result, *args): args[0].return_value = mock_result - with mock.patch('six.moves.builtins.open', mock.mock_open()) as m_open: + with mock.patch('builtins.open', mock.mock_open()) as m_open: self.assertEqual(self.psrunner.run(name=name), status) m_open.assert_called_once_with( '{}/subunit_stream'.format(self.psrunner.res_dir), 'wb') @@ -135,7 +135,7 @@ class SuiteTesting(unittest.TestCase): decorated=mock.Mock( testsRun=50, errors=[], failures=[])) args[3].side_effect = exc - with mock.patch('six.moves.builtins.open', + with mock.patch('builtins.open', mock.mock_open()) as m_open: self.assertEqual( self.psrunner.run(), testcase.TestCase.EX_RUN_ERROR) -- cgit 1.2.3-korg