Drop six 82/72582/3
authorVincent Danno <vincent.danno@orange.com>
Wed, 26 May 2021 11:08:55 +0000 (13:08 +0200)
committerVincent Danno <vincent.danno@orange.com>
Tue, 1 Jun 2021 18:40:32 +0000 (20:40 +0200)
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 <vincent.danno@orange.com>
Change-Id: I840211990b76f77a46e9e737fc4a4c857b57c0b2

18 files changed:
requirements.txt
xtesting/ci/run_tests.py
xtesting/core/behaveframework.py
xtesting/core/campaign.py
xtesting/core/feature.py
xtesting/core/mts.py
xtesting/core/robotframework.py
xtesting/core/testcase.py
xtesting/core/unit.py
xtesting/samples/first.py
xtesting/samples/second.py
xtesting/tests/unit/ci/test_run_tests.py
xtesting/tests/unit/ci/test_tier_builder.py
xtesting/tests/unit/core/test_behaveframework.py
xtesting/tests/unit/core/test_feature.py
xtesting/tests/unit/core/test_unit.py
xtesting/tests/unit/utils/test_env.py
xtesting/utils/decorators.py

index 7e4804d..7394867 100644 (file)
@@ -11,7 +11,6 @@ behave>=1.2.6
 behave-html-formatter>=0.9.4;python_version>='3.6'
 mock!=4.0.0,!=4.0.1 # BSD
 PrettyTable<0.8 # BSD
-six # MIT
 python-subunit # Apache-2.0/BSD
 os-testr # Apache-2.0
 junitxml
index 989969b..4477ded 100644 (file)
@@ -25,7 +25,6 @@ import textwrap
 import enum
 import pkg_resources
 import prettytable
-import six
 from stevedore import driver
 import yaml
 
@@ -311,7 +310,7 @@ def main():
         os.makedirs(constants.RESULTS_DIR)
     except OSError as ex:
         if ex.errno != errno.EEXIST:
-            six.print_("{} {}".format("Cannot create", constants.RESULTS_DIR))
+            print("{} {}".format("Cannot create", constants.RESULTS_DIR))
             return testcase.TestCase.EX_RUN_ERROR
     if env.get('DEBUG').lower() == 'true':
         logging.config.fileConfig(pkg_resources.resource_filename(
index dba556f..e288fff 100644 (file)
@@ -16,7 +16,6 @@ import os
 import time
 
 import json
-import six
 
 from behave.__main__ import main as behave_main
 
@@ -92,10 +91,9 @@ class BehaveFramework(testcase.TestCase):
         config = ['--tags='+','.join(tags),
                   '--junit', '--junit-directory={}'.format(self.res_dir),
                   '--format=json', '--outfile={}'.format(self.json_file)]
-        if six.PY3:
-            html_file = os.path.join(self.res_dir, 'output.html')
-            config += ['--format=behave_html_formatter:HTMLFormatter',
-                       '--outfile={}'.format(html_file)]
+        html_file = os.path.join(self.res_dir, 'output.html')
+        config += ['--format=behave_html_formatter:HTMLFormatter',
+                   '--outfile={}'.format(html_file)]
         if kwargs.get("console", False):
             config += ['--format=pretty', '--outfile=-']
         for feature in suites:
index 51a145c..5874768 100644 (file)
@@ -17,12 +17,12 @@ import os
 import re
 import zipfile
 
+from urllib.parse import urlparse
 import boto3
 from boto3.s3.transfer import TransferConfig
 import botocore
 import pkg_resources
 import requests
-from six.moves import urllib
 
 from xtesting.core import testcase
 from xtesting.utils import env
@@ -120,9 +120,9 @@ class Campaign():
             multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
                 "S3_ENDPOINT_URL"] else 8 * 1024 * 1024
             config = TransferConfig(multipart_threshold=multipart_threshold)
-            bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+            bucket_name = urlparse(dst_s3_url).netloc
             s3path = re.search(
-                '^/*(.*)/*$', urllib.parse.urlparse(dst_s3_url).path).group(1)
+                '^/*(.*)/*$', urlparse(dst_s3_url).path).group(1)
             prefix = os.path.join(s3path, build_tag)
             # pylint: disable=no-member
             for s3_object in b3resource.Bucket(bucket_name).objects.filter(
@@ -183,9 +183,9 @@ class Campaign():
             multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
                 "S3_ENDPOINT_URL"] else 8 * 1024 * 1024
             config = TransferConfig(multipart_threshold=multipart_threshold)
-            bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+            bucket_name = urlparse(dst_s3_url).netloc
             mime_type = mimetypes.guess_type('{}.zip'.format(build_tag))
-            path = urllib.parse.urlparse(dst_s3_url).path.strip("/")
+            path = urlparse(dst_s3_url).path.strip("/")
             # pylint: disable=no-member
             b3resource.Bucket(bucket_name).upload_file(
                 '{}.zip'.format(build_tag),
index 3b2a19f..f92858b 100644 (file)
@@ -20,15 +20,13 @@ import subprocess
 import sys
 import time
 
-import six
 from xtesting.core import testcase
 
 __author__ = ("Serena Feng <feng.xiaowei@zte.com.cn>, "
               "Cedric Ollivier <cedric.ollivier@orange.com>")
 
 
-@six.add_metaclass(abc.ABCMeta)
-class Feature(testcase.TestCase):
+class Feature(testcase.TestCase, metaclass=abc.ABCMeta):
     """Base model for single feature."""
 
     __logger = logging.getLogger(__name__)
index d6865a6..6ced253 100644 (file)
@@ -25,7 +25,6 @@ import time
 
 from lxml import etree
 import prettytable
-import six
 
 from xtesting.core import testcase
 
@@ -245,17 +244,14 @@ class MTSLauncher(testcase.TestCase):
                     if console:
                         sys.stdout.write(line.decode("utf-8"))
                     f_stdout.write(line.decode("utf-8"))
-                if six.PY3:
-                    try:
-                        process.wait(timeout=max_duration)
-                    except subprocess.TimeoutExpired:
-                        process.kill()
-                        self.__logger.info(
-                            "Killing MTS process after %d second(s).",
-                            max_duration)
-                        return 3
-                else:
-                    process.wait()
+                try:
+                    process.wait(timeout=max_duration)
+                except subprocess.TimeoutExpired:
+                    process.kill()
+                    self.__logger.info(
+                        "Killing MTS process after %d second(s).",
+                        max_duration)
+                    return 3
             with open(self.result_file, 'r') as f_stdin:
                 self.__logger.debug("$ %s\n%s", cmd, f_stdin.read().rstrip())
             return process.returncode
index a973e9a..64ee352 100644 (file)
@@ -14,12 +14,12 @@ from __future__ import division
 import logging
 import os
 
+from io import StringIO
 import robot.api
 from robot.errors import RobotError
 from robot.reporting import resultwriter
 import robot.run
 from robot.utils.robottime import timestamp_to_secs
-from six import StringIO
 
 from xtesting.core import testcase
 
index 08ce426..15936f1 100644 (file)
@@ -16,15 +16,13 @@ import logging
 import mimetypes
 import os
 import re
-import sys
 
+from urllib.parse import urlparse
 import boto3
 from boto3.s3.transfer import TransferConfig
 import botocore
 import prettytable
 import requests
-import six
-from six.moves import urllib
 
 from xtesting.utils import decorators
 from xtesting.utils import env
@@ -33,8 +31,7 @@ from xtesting.utils import constants
 __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
 
 
-@six.add_metaclass(abc.ABCMeta)
-class TestCase():
+class TestCase(metaclass=abc.ABCMeta):
     # pylint: disable=too-many-instance-attributes
     """Base model for single test case."""
 
@@ -238,7 +235,7 @@ class TestCase():
                 url, data=json.dumps(data, sort_keys=True),
                 headers=self.headers)
             req.raise_for_status()
-            if urllib.parse.urlparse(url).scheme != "file":
+            if urlparse(url).scheme != "file":
                 # href must be postprocessed as OPNFV testapi is misconfigured
                 # (localhost is returned)
                 uid = re.sub(r'^.*/api/v1/results/*', '', req.json()["href"])
@@ -289,7 +286,7 @@ class TestCase():
             multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
                 "S3_ENDPOINT_URL"] else 8 * 1024 * 1024
             config = TransferConfig(multipart_threshold=multipart_threshold)
-            bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+            bucket_name = urlparse(dst_s3_url).netloc
             try:
                 b3resource.meta.client.head_bucket(Bucket=bucket_name)
             except botocore.exceptions.ClientError as exc:
@@ -298,12 +295,10 @@ class TestCase():
                     # pylint: disable=no-member
                     b3resource.create_bucket(Bucket=bucket_name)
                 else:
-                    typ, value, traceback = sys.exc_info()
-                    six.reraise(typ, value, traceback)
-            except Exception:  # pylint: disable=broad-except
-                typ, value, traceback = sys.exc_info()
-                six.reraise(typ, value, traceback)
-            path = urllib.parse.urlparse(dst_s3_url).path.strip("/")
+                    raise exc
+            except Exception as exc:  # pylint: disable=broad-except
+                raise exc
+            path = urlparse(dst_s3_url).path.strip("/")
             dst_http_url = os.environ["HTTP_DST_URL"]
             output_str = "\n"
             self.details["links"] = []
index 877cd07..9d549a2 100644 (file)
@@ -10,7 +10,7 @@
 """Define the parent class to run unittest.TestSuite as TestCase."""
 
 from __future__ import division
-
+from io import BytesIO
 import logging
 import os
 import shutil
@@ -19,7 +19,6 @@ import time
 import unittest
 
 from subunit.run import SubunitTestRunner
-import six
 
 from xtesting.core import testcase
 
@@ -112,7 +111,7 @@ class Suite(testcase.TestCase):
             self.start_time = time.time()
             if not os.path.isdir(self.res_dir):
                 os.makedirs(self.res_dir)
-            stream = six.BytesIO()
+            stream = BytesIO()
             result = SubunitTestRunner(
                 stream=stream, verbosity=2).run(self.suite).decorated
             self.generate_stats(stream)
index e8a17b2..5e240ed 100644 (file)
@@ -11,8 +11,6 @@
 
 import time
 
-import six
-
 from xtesting.core import testcase
 
 
@@ -20,6 +18,6 @@ class Test(testcase.TestCase):
 
     def run(self, **kwargs):
         self.start_time = time.time()
-        six.print_("Hello World")
+        print("Hello World")
         self.result = 100
         self.stop_time = time.time()
index 5e1b105..af198e1 100644 (file)
@@ -9,13 +9,11 @@
 
 # pylint: disable=missing-docstring
 
-import six
-
 from xtesting.core import feature
 
 
 class Test(feature.Feature):
 
     def execute(self, **kwargs):
-        six.print_("Hello World")
+        print("Hello World")
         return 0
index 423bf48..b206a49 100644 (file)
@@ -94,7 +94,7 @@ class RunTestsTesting(unittest.TestCase):
         except Exception:  # pylint: disable=broad-except
             pass
         envfile = 'rc_file'
-        with mock.patch('six.moves.builtins.open',
+        with mock.patch('builtins.open',
                         mock.mock_open(read_data=msg)) as mock_method,\
                 mock.patch('os.path.isfile', return_value=True):
             mock_method.return_value.__iter__ = lambda self: iter(
@@ -117,7 +117,7 @@ class RunTestsTesting(unittest.TestCase):
             'export "\'OS_TENANT_NAME\'" = "\'admin\'"')
 
     def test_get_dict_by_test(self):
-        with mock.patch('six.moves.builtins.open', mock.mock_open()), \
+        with mock.patch('builtins.open', mock.mock_open()), \
                 mock.patch('yaml.safe_load') as mock_yaml:
             mock_obj = mock.Mock()
             testcase_dict = {'case_name': 'testname',
index 70b5aea..091142e 100644 (file)
@@ -38,7 +38,7 @@ class TierBuilderTesting(unittest.TestCase):
 
         with mock.patch('xtesting.ci.tier_builder.yaml.safe_load',
                         return_value=self.mock_yaml), \
-                mock.patch('six.moves.builtins.open', mock.mock_open()):
+                mock.patch('builtins.open', mock.mock_open()):
             os.environ["INSTALLER_TYPE"] = 'test_installer'
             os.environ["DEPLOY_SCENARIO"] = 'test_scenario'
             self.tierbuilder = tier_builder.TierBuilder('testcases_file')
index 754813a..72fa6f2 100644 (file)
@@ -14,7 +14,6 @@ import os
 import unittest
 
 import mock
-import six
 
 from xtesting.core import behaveframework
 
@@ -32,26 +31,26 @@ class ParseResultTesting(unittest.TestCase):
         self.test = behaveframework.BehaveFramework(
             case_name='behave', project_name='xtesting')
 
-    @mock.patch('six.moves.builtins.open', side_effect=OSError)
+    @mock.patch('builtins.open', side_effect=OSError)
     def test_raises_exc_open(self, *args):  # pylint: disable=unused-argument
         with self.assertRaises(OSError):
             self.test.parse_results()
 
     @mock.patch('json.load', return_value=[{'foo': 'bar'}])
-    @mock.patch('six.moves.builtins.open', mock.mock_open())
+    @mock.patch('builtins.open', mock.mock_open())
     def test_raises_exc_key(self, *args):  # pylint: disable=unused-argument
         with self.assertRaises(KeyError):
             self.test.parse_results()
 
     @mock.patch('json.load', return_value=[])
-    @mock.patch('six.moves.builtins.open', mock.mock_open())
+    @mock.patch('builtins.open', mock.mock_open())
     def test_raises_exe_zerodivision(self, *args):
         # pylint: disable=unused-argument
         with self.assertRaises(ZeroDivisionError):
             self.test.parse_results()
 
     def _test_result(self, response, result):
-        with mock.patch('six.moves.builtins.open', mock.mock_open()), \
+        with mock.patch('builtins.open', mock.mock_open()), \
                 mock.patch('json.load', return_value=response):
             self.test.parse_results()
             self.assertEqual(self.test.result, result)
@@ -68,7 +67,7 @@ class ParseResultTesting(unittest.TestCase):
         data = [{'status': 'passed'}, {'status': 'passed'}]
         self._test_result(data, 100)
 
-    @mock.patch('six.moves.builtins.open', mock.mock_open())
+    @mock.patch('builtins.open', mock.mock_open())
     def test_count(self, *args):  # pylint: disable=unused-argument
         self._response.extend([{'status': 'failed'}, {'status': 'skipped'}])
         with mock.patch('json.load', mock.Mock(return_value=self._response)):
@@ -121,11 +120,9 @@ class RunTesting(unittest.TestCase):
             args_list = [
                 '--tags=', '--junit',
                 '--junit-directory={}'.format(self.test.res_dir),
-                '--format=json', '--outfile={}'.format(self.test.json_file)]
-            if six.PY3:
-                args_list += [
-                    '--format=behave_html_formatter:HTMLFormatter',
-                    '--outfile={}'.format(html_file)]
+                '--format=json', '--outfile={}'.format(self.test.json_file),
+                '--format=behave_html_formatter:HTMLFormatter',
+                '--outfile={}'.format(html_file)]
             args_list.append('foo')
             args[0].assert_called_once_with(args_list)
             mock_method.assert_called_once_with()
@@ -155,11 +152,9 @@ class RunTesting(unittest.TestCase):
         args_list = [
             '--tags=', '--junit',
             '--junit-directory={}'.format(self.test.res_dir),
-            '--format=json', '--outfile={}'.format(self.test.json_file)]
-        if six.PY3:
-            args_list += [
-                '--format=behave_html_formatter:HTMLFormatter',
-                '--outfile={}'.format(html_file)]
+            '--format=json', '--outfile={}'.format(self.test.json_file),
+            '--format=behave_html_formatter:HTMLFormatter',
+            '--outfile={}'.format(html_file)]
         if console:
             args_list += ['--format=pretty', '--outfile=-']
         args_list.append('foo')
index ab483b2..b36fa36 100644 (file)
 
 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)
index 3be4144..8657771 100644 (file)
@@ -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)
index 08601fa..83b1a19 100644 (file)
@@ -12,8 +12,7 @@
 import logging
 import os
 import unittest
-
-from six.moves import reload_module
+import importlib
 
 from xtesting.utils import env
 
@@ -32,7 +31,7 @@ class EnvTesting(unittest.TestCase):
 
     def test_get_unknown_env(self):
         self.assertEqual(env.get('FOO'), 'foo')
-        reload_module(env)
+        importlib.reload(env)
 
     def test_get_unset_env(self):
         del os.environ['CI_LOOP']
index 230a99e..2ce12fa 100644 (file)
 import errno
 import functools
 import os
+from urllib.parse import urlparse
 
 import mock
 import requests.sessions
-from six.moves import urllib
 
 
 def can_dump_request_to_file(method):
 
     def dump_preparedrequest(request, **kwargs):
         # pylint: disable=unused-argument
-        parseresult = urllib.parse.urlparse(request.url)
+        parseresult = urlparse(request.url)
         if parseresult.scheme == "file":
             try:
                 dirname = os.path.dirname(parseresult.path)
@@ -41,7 +41,7 @@ def can_dump_request_to_file(method):
 
     def patch_request(method, url, **kwargs):
         with requests.sessions.Session() as session:
-            parseresult = urllib.parse.urlparse(url)
+            parseresult = urlparse(url)
             if parseresult.scheme == "file":
                 with mock.patch.object(session, 'send',
                                        side_effect=dump_preparedrequest):