diff options
Diffstat (limited to 'setuptools/tests/test_easy_install.py')
| -rw-r--r-- | setuptools/tests/test_easy_install.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index b8918b17..bc025970 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -15,17 +15,18 @@ import contextlib import tarfile import logging import itertools +import io +import six +from six.moves import urllib import pytest import mock from setuptools import sandbox -from setuptools import compat -from setuptools.compat import StringIO, BytesIO, urlparse from setuptools.sandbox import run_setup, SandboxViolation from setuptools.command.easy_install import ( easy_install, fix_jython_executable, get_script_args, nt_quote_arg, - get_script_header, + get_script_header, is_sh, ) from setuptools.command.easy_install import PthDistributions from setuptools.command import easy_install as easy_install_pkg @@ -289,7 +290,7 @@ class TestSetupRequires: p_index = setuptools.tests.server.MockServer() p_index.start() netloc = 1 - p_index_loc = urlparse(p_index.url)[netloc] + p_index_loc = urllib.parse.urlparse(p_index.url)[netloc] if p_index_loc.endswith(':0'): # Some platforms (Jython) don't find a port to which to bind, # so skip this test for them. @@ -412,12 +413,7 @@ def make_trivial_sdist(dist_path, setup_py): """ setup_py_file = tarfile.TarInfo(name='setup.py') - try: - # Python 3 (StringIO gets converted to io module) - MemFile = BytesIO - except AttributeError: - MemFile = StringIO - setup_py_bytes = MemFile(setup_py.encode('utf-8')) + setup_py_bytes = io.BytesIO(setup_py.encode('utf-8')) setup_py_file.size = len(setup_py_bytes.getvalue()) with tarfile_open(dist_path, 'w:gz') as dist: dist.addfile(setup_py_file, fileobj=setup_py_bytes) @@ -443,7 +439,7 @@ class TestScriptHeader: def test_get_script_header_jython_workaround(self): # This test doesn't work with Python 3 in some locales - if compat.PY3 and os.environ.get("LC_CTYPE") in (None, "C", "POSIX"): + if six.PY3 and os.environ.get("LC_CTYPE") in (None, "C", "POSIX"): return class java: @@ -468,12 +464,12 @@ class TestScriptHeader: # Ensure we generate what is basically a broken shebang line # when there's options, with a warning emitted - sys.stdout = sys.stderr = StringIO() + sys.stdout = sys.stderr = six.StringIO() candidate = get_script_header('#!/usr/bin/python -x', executable=exe) assert candidate == '#!%s -x\n' % exe assert 'Unable to adapt shebang line' in sys.stdout.getvalue() - sys.stdout = sys.stderr = StringIO() + sys.stdout = sys.stderr = six.StringIO() candidate = get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe) assert candidate == '#!%s -x\n' % self.non_ascii_exe |
