summaryrefslogtreecommitdiff
path: root/setuptools/tests
diff options
context:
space:
mode:
authormergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-08-16 12:34:46 +0000
committerGitHub <noreply@github.com>2020-08-16 12:34:46 +0000
commitf991fbb3c9d0e10a0a78ae2b508b3fd99f9cdef2 (patch)
treea044b31a3276cc4a51b7fc23776a32b380562bad /setuptools/tests
parent4eb5b32f8d8bb1e20907028a516346e2b1901391 (diff)
parent45e0ea0ff10a64f315a5c65b6805327222e5b565 (diff)
downloadpython-setuptools-git-f991fbb3c9d0e10a0a78ae2b508b3fd99f9cdef2.tar.gz
Merge pull request #2332 from pypa/debt/cleanup-py2
Remove legacy Python 2 code
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/__init__.py9
-rw-r--r--setuptools/tests/contexts.py6
-rw-r--r--setuptools/tests/namespaces.py2
-rw-r--r--setuptools/tests/server.py21
-rw-r--r--setuptools/tests/test_archive_util.py6
-rw-r--r--setuptools/tests/test_build_ext.py4
-rw-r--r--setuptools/tests/test_build_meta.py20
-rw-r--r--setuptools/tests/test_config.py24
-rw-r--r--setuptools/tests/test_develop.py7
-rw-r--r--setuptools/tests/test_dist.py20
-rw-r--r--setuptools/tests/test_dist_info.py4
-rw-r--r--setuptools/tests/test_easy_install.py8
-rw-r--r--setuptools/tests/test_egg_info.py52
-rw-r--r--setuptools/tests/test_extern.py2
-rw-r--r--setuptools/tests/test_find_packages.py11
-rw-r--r--setuptools/tests/test_integration.py2
-rw-r--r--setuptools/tests/test_manifest.py6
-rw-r--r--setuptools/tests/test_msvc14.py2
-rw-r--r--setuptools/tests/test_namespaces.py2
-rw-r--r--setuptools/tests/test_packageindex.py11
-rw-r--r--setuptools/tests/test_sdist.py77
-rw-r--r--setuptools/tests/test_setopt.py10
-rw-r--r--setuptools/tests/test_setuptools.py3
-rw-r--r--setuptools/tests/test_test.py5
-rw-r--r--setuptools/tests/test_virtualenv.py11
-rw-r--r--setuptools/tests/test_wheel.py2
-rw-r--r--setuptools/tests/test_windows_wrappers.py2
-rw-r--r--setuptools/tests/text.py5
-rw-r--r--setuptools/tests/textwrap.py2
29 files changed, 65 insertions, 271 deletions
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index 6377d785..a7a2112f 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -2,19 +2,12 @@ import locale
import pytest
-from setuptools.extern.six import PY2, PY3
-
-__all__ = [
- 'fail_on_ascii', 'py2_only', 'py3_only', 'ack_2to3'
-]
+__all__ = ['fail_on_ascii', 'ack_2to3']
is_ascii = locale.getpreferredencoding() == 'ANSI_X3.4-1968'
fail_on_ascii = pytest.mark.xfail(is_ascii, reason="Test fails in this locale")
-py2_only = pytest.mark.skipif(not PY2, reason="Test runs on Python 2 only")
-py3_only = pytest.mark.skipif(not PY3, reason="Test runs on Python 3 only")
-
ack_2to3 = pytest.mark.filterwarnings('ignore:2to3 support is deprecated')
diff --git a/setuptools/tests/contexts.py b/setuptools/tests/contexts.py
index 535ae107..51ce8984 100644
--- a/setuptools/tests/contexts.py
+++ b/setuptools/tests/contexts.py
@@ -4,8 +4,8 @@ import shutil
import sys
import contextlib
import site
+import io
-from setuptools.extern import six
import pkg_resources
@@ -58,8 +58,8 @@ def quiet():
old_stdout = sys.stdout
old_stderr = sys.stderr
- new_stdout = sys.stdout = six.StringIO()
- new_stderr = sys.stderr = six.StringIO()
+ new_stdout = sys.stdout = io.StringIO()
+ new_stderr = sys.stderr = io.StringIO()
try:
yield new_stdout, new_stderr
finally:
diff --git a/setuptools/tests/namespaces.py b/setuptools/tests/namespaces.py
index ef5ecdad..245cf8ea 100644
--- a/setuptools/tests/namespaces.py
+++ b/setuptools/tests/namespaces.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, unicode_literals
-
import textwrap
diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py
index 8b17b081..7e213230 100644
--- a/setuptools/tests/server.py
+++ b/setuptools/tests/server.py
@@ -4,13 +4,12 @@
import os
import time
import threading
+import http.server
+import urllib.parse
+import urllib.request
-from setuptools.extern.six.moves import BaseHTTPServer, SimpleHTTPServer
-from setuptools.extern.six.moves.urllib_parse import urljoin
-from setuptools.extern.six.moves.urllib.request import pathname2url
-
-class IndexServer(BaseHTTPServer.HTTPServer):
+class IndexServer(http.server.HTTPServer):
"""Basic single-threaded http server simulating a package index
You can use this server in unittest like this::
@@ -24,8 +23,8 @@ class IndexServer(BaseHTTPServer.HTTPServer):
def __init__(
self, server_address=('', 0),
- RequestHandlerClass=SimpleHTTPServer.SimpleHTTPRequestHandler):
- BaseHTTPServer.HTTPServer.__init__(
+ RequestHandlerClass=http.server.SimpleHTTPRequestHandler):
+ http.server.HTTPServer.__init__(
self, server_address, RequestHandlerClass)
self._run = True
@@ -48,14 +47,14 @@ class IndexServer(BaseHTTPServer.HTTPServer):
return 'http://127.0.0.1:%s/setuptools/tests/indexes/' % port
-class RequestRecorder(BaseHTTPServer.BaseHTTPRequestHandler):
+class RequestRecorder(http.server.BaseHTTPRequestHandler):
def do_GET(self):
requests = vars(self.server).setdefault('requests', [])
requests.append(self)
self.send_response(200, 'OK')
-class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
+class MockServer(http.server.HTTPServer, threading.Thread):
"""
A simple HTTP Server that records the requests made to it.
"""
@@ -63,7 +62,7 @@ class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
def __init__(
self, server_address=('', 0),
RequestHandlerClass=RequestRecorder):
- BaseHTTPServer.HTTPServer.__init__(
+ http.server.HTTPServer.__init__(
self, server_address, RequestHandlerClass)
threading.Thread.__init__(self)
self.setDaemon(True)
@@ -87,5 +86,5 @@ def path_to_url(path, authority=None):
base = 'file:'
if authority is not None:
base += '//' + authority
- url = urljoin(base, pathname2url(path))
+ url = urllib.parse.urljoin(base, urllib.request.pathname2url(path))
return url
diff --git a/setuptools/tests/test_archive_util.py b/setuptools/tests/test_archive_util.py
index b789e9ac..7f996244 100644
--- a/setuptools/tests/test_archive_util.py
+++ b/setuptools/tests/test_archive_util.py
@@ -3,8 +3,6 @@
import tarfile
import io
-from setuptools.extern import six
-
import pytest
from setuptools import archive_util
@@ -22,8 +20,6 @@ def tarfile_with_unicode(tmpdir):
data = b""
filename = "testimäge.png"
- if six.PY2:
- filename = filename.decode('utf-8')
t = tarfile.TarInfo(filename)
t.size = len(data)
@@ -39,4 +35,4 @@ def tarfile_with_unicode(tmpdir):
@pytest.mark.xfail(reason="#710 and #712")
def test_unicode_files(tarfile_with_unicode, tmpdir):
target = tmpdir / 'out'
- archive_util.unpack_archive(tarfile_with_unicode, six.text_type(target))
+ archive_util.unpack_archive(tarfile_with_unicode, str(target))
diff --git a/setuptools/tests/test_build_ext.py b/setuptools/tests/test_build_ext.py
index 2ef8521d..838fdb42 100644
--- a/setuptools/tests/test_build_ext.py
+++ b/setuptools/tests/test_build_ext.py
@@ -2,8 +2,6 @@ import sys
import distutils.command.build_ext as orig
from distutils.sysconfig import get_config_var
-from setuptools.extern import six
-
from setuptools.command.build_ext import build_ext, get_abi3_suffix
from setuptools.dist import Distribution
from setuptools.extension import Extension
@@ -41,7 +39,7 @@ class TestBuildExt:
assert 'spam.eggs' in cmd.ext_map
res = cmd.get_ext_filename('spam.eggs')
- if six.PY2 or not get_abi3_suffix():
+ if not get_abi3_suffix():
assert res.endswith(get_config_var('EXT_SUFFIX'))
elif sys.platform == 'win32':
assert res.endswith('eggs.pyd')
diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py
index fdb4b950..5462b26a 100644
--- a/setuptools/tests/test_build_meta.py
+++ b/setuptools/tests/test_build_meta.py
@@ -1,20 +1,13 @@
-from __future__ import unicode_literals
-
import os
import shutil
import tarfile
+import importlib
+from concurrent import futures
import pytest
from .files import build_files
from .textwrap import DALS
-from . import py2_only
-
-__metaclass__ = type
-
-# Backports on Python 2.7
-import importlib
-from concurrent import futures
class BuildBackendBase:
@@ -220,15 +213,6 @@ class TestBuildMetaBackend:
assert os.path.isfile(os.path.join(dist_dir, dist_info, 'METADATA'))
- @py2_only
- def test_prepare_metadata_for_build_wheel_with_str(self, build_backend):
- dist_dir = os.path.abspath(str('pip-dist-info'))
- os.makedirs(dist_dir)
-
- dist_info = build_backend.prepare_metadata_for_build_wheel(dist_dir)
-
- assert os.path.isfile(os.path.join(dist_dir, dist_info, 'METADATA'))
-
def test_build_sdist_explicit_dist(self, build_backend):
# explicitly specifying the dist folder should work
# the folder sdist_directory and the ``--dist-dir`` can be the same
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
index 67992c04..1dee1271 100644
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -1,7 +1,5 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
import contextlib
+import configparser
import pytest
@@ -9,9 +7,6 @@ from distutils.errors import DistutilsOptionError, DistutilsFileError
from mock import patch
from setuptools.dist import Distribution, _Distribution
from setuptools.config import ConfigHandler, read_configuration
-from setuptools.extern.six.moves import configparser
-from setuptools.extern import six
-from . import py2_only, py3_only
from .textwrap import DALS
@@ -311,10 +306,6 @@ class TestMetadata:
with get_dist(tmpdir) as dist:
assert dist.metadata.version == '2016.11.26'
- if six.PY2:
- # static version loading is unsupported on Python 2
- return
-
config.write(
'[metadata]\n'
'version = attr: fake_package.subpkg_b.mod.VERSION\n'
@@ -719,19 +710,6 @@ class TestOptions:
assert set(dist.packages) == set(
['fake_package', 'fake_package.sub_two'])
- @py2_only
- def test_find_namespace_directive_fails_on_py2(self, tmpdir):
- dir_package, config = fake_env(
- tmpdir,
- '[options]\n'
- 'packages = find_namespace:\n'
- )
-
- with pytest.raises(DistutilsOptionError):
- with get_dist(tmpdir) as dist:
- dist.parse_config_files()
-
- @py3_only
def test_find_namespace_directive(self, tmpdir):
dir_package, config = fake_env(
tmpdir,
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py
index bb89a865..9854420e 100644
--- a/setuptools/tests/test_develop.py
+++ b/setuptools/tests/test_develop.py
@@ -1,8 +1,6 @@
"""develop tests
"""
-from __future__ import absolute_import, unicode_literals
-
import os
import site
import sys
@@ -10,7 +8,6 @@ import io
import subprocess
import platform
-from setuptools.extern import six
from setuptools.command import test
import pytest
@@ -97,7 +94,7 @@ class TestDevelop:
with io.open(fn) as init_file:
init = init_file.read().strip()
- expected = 'print "foo"' if six.PY2 else 'print("foo")'
+ expected = 'print("foo")'
assert init == expected
def test_console_scripts(self, tmpdir):
@@ -163,7 +160,7 @@ class TestNamespaces:
reason="https://github.com/pypa/setuptools/issues/851",
)
@pytest.mark.skipif(
- platform.python_implementation() == 'PyPy' and not six.PY2,
+ platform.python_implementation() == 'PyPy',
reason="https://github.com/pypa/setuptools/issues/1202",
)
def test_namespace_package_importable(self, tmpdir):
diff --git a/setuptools/tests/test_dist.py b/setuptools/tests/test_dist.py
index 531ea1b4..cb47fb58 100644
--- a/setuptools/tests/test_dist.py
+++ b/setuptools/tests/test_dist.py
@@ -1,11 +1,9 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import unicode_literals
-
import io
import collections
import re
import functools
+import urllib.request
+import urllib.parse
from distutils.errors import DistutilsSetupError
from setuptools.dist import (
_get_unpatched,
@@ -14,9 +12,6 @@ from setuptools.dist import (
)
from setuptools import sic
from setuptools import Distribution
-from setuptools.extern.six.moves.urllib.request import pathname2url
-from setuptools.extern.six.moves.urllib_parse import urljoin
-from setuptools.extern import six
from .textwrap import DALS
from .test_easy_install import make_nspkg_sdist
@@ -29,7 +24,8 @@ def test_dist_fetch_build_egg(tmpdir):
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
"""
index = tmpdir.mkdir('index')
- index_url = urljoin('file://', pathname2url(str(index)))
+ index_url = urllib.parse.urljoin(
+ 'file://', urllib.request.pathname2url(str(index)))
def sdist_with_index(distname, version):
dist_dir = index.mkdir(distname)
@@ -63,8 +59,7 @@ def test_dist_fetch_build_egg(tmpdir):
dist.fetch_build_egg(r)
for r in reqs
]
- # noqa below because on Python 2 it causes flakes
- assert [dist.key for dist in resolved_dists if dist] == reqs # noqa
+ assert [dist.key for dist in resolved_dists if dist] == reqs
def test_dist__get_unpatched_deprecated():
@@ -150,10 +145,7 @@ def test_read_metadata(name, attrs):
dist_class = metadata_out.__class__
# Write to PKG_INFO and then load into a new metadata object
- if six.PY2:
- PKG_INFO = io.BytesIO()
- else:
- PKG_INFO = io.StringIO()
+ PKG_INFO = io.StringIO()
metadata_out.write_pkg_file(PKG_INFO)
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py
index f7e7d2bf..29fbd09d 100644
--- a/setuptools/tests/test_dist_info.py
+++ b/setuptools/tests/test_dist_info.py
@@ -1,10 +1,6 @@
"""Test .dist-info style distributions.
"""
-from __future__ import unicode_literals
-
-from setuptools.extern.six.moves import map
-
import pytest
import pkg_resources
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index c07b5bea..26a5e9a6 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -1,7 +1,5 @@
-# -*- coding: utf-8 -*-
"""Easy install Tests
"""
-from __future__ import absolute_import, unicode_literals
import sys
import os
@@ -18,8 +16,6 @@ import mock
import time
import re
-from setuptools.extern import six
-
import pytest
from setuptools import sandbox
@@ -41,8 +37,6 @@ from . import contexts
from .files import build_files
from .textwrap import DALS
-__metaclass__ = type
-
class FakeDist:
def get_entry_map(self, group):
@@ -984,8 +978,6 @@ def create_setup_requires_package(path, distname='foobar', version='0.1',
)
class TestScriptHeader:
non_ascii_exe = '/Users/José/bin/python'
- if six.PY2:
- non_ascii_exe = non_ascii_exe.encode('utf-8')
exe_with_spaces = r'C:\Program Files\Python36\python.exe'
def test_get_script_header(self):
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 109f9135..dc472af4 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -10,7 +10,6 @@ from setuptools.command.egg_info import (
egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision,
)
from setuptools.dist import Distribution
-from setuptools.extern.six.moves import map
import pytest
@@ -19,8 +18,6 @@ from .files import build_files
from .textwrap import DALS
from . import contexts
-__metaclass__ = type
-
class Environment(str):
pass
@@ -73,8 +70,7 @@ class TestEggInfo:
"""
When the egg_info section is empty or not present, running
save_version_info should add the settings to the setup.cfg
- in a deterministic order, consistent with the ordering found
- on Python 2.7 with PYTHONHASHSEED=0.
+ in a deterministic order.
"""
setup_cfg = os.path.join(env.paths['home'], 'setup.cfg')
dist = Distribution()
@@ -906,49 +902,3 @@ class TestEggInfo:
def test_get_pkg_info_revision_deprecated(self):
pytest.warns(EggInfoDeprecationWarning, get_pkg_info_revision)
-
- EGG_INFO_TESTS = (
- # Check for issue #1136: invalid string type when
- # reading declarative `setup.cfg` under Python 2.
- {
- 'setup.py': DALS(
- """
- from setuptools import setup
- setup(
- name="foo",
- )
- """),
- 'setup.cfg': DALS(
- """
- [options]
- package_dir =
- = src
- """),
- 'src': {},
- },
- # Check Unicode can be used in `setup.py` under Python 2.
- {
- 'setup.py': DALS(
- """
- # -*- coding: utf-8 -*-
- from __future__ import unicode_literals
- from setuptools import setup, find_packages
- setup(
- name="foo",
- package_dir={'': 'src'},
- )
- """),
- 'src': {},
- }
- )
-
- @pytest.mark.parametrize('package_files', EGG_INFO_TESTS)
- def test_egg_info(self, tmpdir_cwd, env, package_files):
- """
- """
- build_files(package_files)
- code, data = environment.run_setup_py(
- cmd=['egg_info'],
- data_stream=1,
- )
- assert not code, data
diff --git a/setuptools/tests/test_extern.py b/setuptools/tests/test_extern.py
index 3519a680..0d6b164f 100644
--- a/setuptools/tests/test_extern.py
+++ b/setuptools/tests/test_extern.py
@@ -3,7 +3,6 @@ import pickle
from setuptools import Distribution
from setuptools.extern import ordered_set
-from setuptools.tests import py3_only
def test_reimport_extern():
@@ -17,6 +16,5 @@ def test_orderedset_pickle_roundtrip():
assert o1 == o2
-@py3_only
def test_distribution_picklable():
pickle.loads(pickle.dumps(Distribution()))
diff --git a/setuptools/tests/test_find_packages.py b/setuptools/tests/test_find_packages.py
index ab26b4f1..906713f6 100644
--- a/setuptools/tests/test_find_packages.py
+++ b/setuptools/tests/test_find_packages.py
@@ -7,12 +7,8 @@ import platform
import pytest
-from . import py3_only
-
-from setuptools.extern.six import PY3
from setuptools import find_packages
-if PY3:
- from setuptools import find_namespace_packages
+from setuptools import find_namespace_packages
# modeled after CPython's test.support.can_symlink
@@ -154,34 +150,29 @@ class TestFindPackages:
def _assert_packages(self, actual, expected):
assert set(actual) == set(expected)
- @py3_only
def test_pep420_ns_package(self):
packages = find_namespace_packages(
self.dist_dir, include=['pkg*'], exclude=['pkg.subpkg.assets'])
self._assert_packages(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])
- @py3_only
def test_pep420_ns_package_no_includes(self):
packages = find_namespace_packages(
self.dist_dir, exclude=['pkg.subpkg.assets'])
self._assert_packages(
packages, ['docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg'])
- @py3_only
def test_pep420_ns_package_no_includes_or_excludes(self):
packages = find_namespace_packages(self.dist_dir)
expected = [
'docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg', 'pkg.subpkg.assets']
self._assert_packages(packages, expected)
- @py3_only
def test_regular_package_with_nested_pep420_ns_packages(self):
self._touch('__init__.py', self.pkg_dir)
packages = find_namespace_packages(
self.dist_dir, exclude=['docs', 'pkg.subpkg.assets'])
self._assert_packages(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])
- @py3_only
def test_pep420_ns_package_no_non_package_dirs(self):
shutil.rmtree(self.docs_dir)
shutil.rmtree(os.path.join(self.dist_dir, 'pkg/subpkg/assets'))
diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py
index f1a27f8b..24cef480 100644
--- a/setuptools/tests/test_integration.py
+++ b/setuptools/tests/test_integration.py
@@ -11,8 +11,8 @@ import subprocess
import functools
import tarfile
import zipfile
+import urllib.request
-from setuptools.extern.six.moves import urllib
import pytest
from setuptools.command.easy_install import easy_install
diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py
index 042a8b17..82bdb9c6 100644
--- a/setuptools/tests/test_manifest.py
+++ b/setuptools/tests/test_manifest.py
@@ -7,18 +7,16 @@ import shutil
import sys
import tempfile
import itertools
+import io
from distutils import log
from distutils.errors import DistutilsTemplateError
from setuptools.command.egg_info import FileList, egg_info, translate_pattern
from setuptools.dist import Distribution
-from setuptools.extern import six
from setuptools.tests.textwrap import DALS
import pytest
-__metaclass__ = type
-
def make_local_path(s):
"""Converts '/' in a string to os.sep"""
@@ -41,7 +39,7 @@ setup(**%r)
@contextlib.contextmanager
def quiet():
old_stdout, old_stderr = sys.stdout, sys.stderr
- sys.stdout, sys.stderr = six.StringIO(), six.StringIO()
+ sys.stdout, sys.stderr = io.StringIO(), io.StringIO()
try:
yield
finally:
diff --git a/setuptools/tests/test_msvc14.py b/setuptools/tests/test_msvc14.py
index 7833aab4..1aca12dd 100644
--- a/setuptools/tests/test_msvc14.py
+++ b/setuptools/tests/test_msvc14.py
@@ -31,8 +31,6 @@ class TestMSVC14:
finally:
_msvccompiler._msvc14_find_vcvarsall = old_find_vcvarsall
- @pytest.mark.skipif(sys.version_info[0] < 3,
- reason="Unicode requires encode/decode on Python 2")
def test_get_vc_env_unicode(self):
import setuptools.msvc as _msvccompiler
diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py
index f937d981..6c8c522d 100644
--- a/setuptools/tests/test_namespaces.py
+++ b/setuptools/tests/test_namespaces.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, unicode_literals
-
import sys
import subprocess
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 29aace13..8e9435ef 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -1,12 +1,11 @@
-from __future__ import absolute_import
-
import sys
import os
import distutils.errors
import platform
+import urllib.request
+import urllib.error
+import http.client
-from setuptools.extern import six
-from setuptools.extern.six.moves import urllib, http_client
import mock
import pytest
@@ -60,7 +59,7 @@ class TestPackageIndex:
)
def _urlopen(*args):
- raise http_client.BadStatusLine('line')
+ raise http.client.BadStatusLine('line')
index.opener = _urlopen
url = 'http://example.com'
@@ -84,7 +83,7 @@ class TestPackageIndex:
try:
index.open_url(url)
except distutils.errors.DistutilsError as error:
- msg = six.text_type(error)
+ msg = str(error)
assert (
'nonnumeric port' in msg
or 'getaddrinfo failed' in msg
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
index 0bea53df..049fdcc0 100644
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -1,8 +1,5 @@
-# -*- coding: utf-8 -*-
"""sdist tests"""
-from __future__ import print_function, unicode_literals
-
import os
import sys
import tempfile
@@ -10,9 +7,6 @@ import unicodedata
import contextlib
import io
-from setuptools.extern import six
-from setuptools.extern.six.moves import map
-
import pytest
import pkg_resources
@@ -21,7 +15,6 @@ from setuptools.command.egg_info import manifest_maker
from setuptools.dist import Distribution
from setuptools.tests import fail_on_ascii
from .text import Filenames
-from . import py3_only
SETUP_ATTRS = {
@@ -42,7 +35,7 @@ setup(**%r)
@contextlib.contextmanager
def quiet():
old_stdout, old_stderr = sys.stdout, sys.stderr
- sys.stdout, sys.stderr = six.StringIO(), six.StringIO()
+ sys.stdout, sys.stderr = io.StringIO(), io.StringIO()
try:
yield
finally:
@@ -51,7 +44,7 @@ def quiet():
# Convert to POSIX path
def posix(path):
- if not six.PY2 and not isinstance(path, str):
+ if not isinstance(path, str):
return path.replace(os.sep.encode('ascii'), b'/')
else:
return path.replace(os.sep, '/')
@@ -59,7 +52,7 @@ def posix(path):
# HFS Plus uses decomposed UTF-8
def decompose(path):
- if isinstance(path, six.text_type):
+ if isinstance(path, str):
return unicodedata.normalize('NFD', path)
try:
path = path.decode('utf-8')
@@ -231,7 +224,6 @@ class TestSdistTest:
# The manifest should contain the UTF-8 filename
assert posix(filename) in u_contents
- @py3_only
@fail_on_ascii
def test_write_manifest_allows_utf8_filenames(self):
# Test for #303.
@@ -265,7 +257,6 @@ class TestSdistTest:
# The filelist should have been updated as well
assert u_filename in mm.filelist.files
- @py3_only
def test_write_manifest_skips_non_utf8_filenames(self):
"""
Files that cannot be encoded to UTF-8 (specifically, those that
@@ -329,11 +320,9 @@ class TestSdistTest:
cmd.read_manifest()
# The filelist should contain the UTF-8 filename
- if not six.PY2:
- filename = filename.decode('utf-8')
+ filename = filename.decode('utf-8')
assert filename in cmd.filelist.files
- @py3_only
@fail_on_latin1_encoded_filenames
def test_read_manifest_skips_non_utf8_filenames(self):
# Test for #303.
@@ -383,21 +372,18 @@ class TestSdistTest:
if sys.platform == 'darwin':
filename = decompose(filename)
- if not six.PY2:
- fs_enc = sys.getfilesystemencoding()
+ fs_enc = sys.getfilesystemencoding()
- if sys.platform == 'win32':
- if fs_enc == 'cp1252':
- # Python 3 mangles the UTF-8 filename
- filename = filename.decode('cp1252')
- assert filename in cmd.filelist.files
- else:
- filename = filename.decode('mbcs')
- assert filename in cmd.filelist.files
+ if sys.platform == 'win32':
+ if fs_enc == 'cp1252':
+ # Python mangles the UTF-8 filename
+ filename = filename.decode('cp1252')
+ assert filename in cmd.filelist.files
else:
- filename = filename.decode('utf-8')
+ filename = filename.decode('mbcs')
assert filename in cmd.filelist.files
else:
+ filename = filename.decode('utf-8')
assert filename in cmd.filelist.files
@classmethod
@@ -425,33 +411,20 @@ class TestSdistTest:
with quiet():
cmd.run()
- if six.PY2:
- # Under Python 2 there seems to be no decoded string in the
- # filelist. However, due to decode and encoding of the
- # file name to get utf-8 Manifest the latin1 maybe excluded
- try:
- # fs_enc should match how one is expect the decoding to
- # be proformed for the manifest output.
- fs_enc = sys.getfilesystemencoding()
- filename.decode(fs_enc)
- assert filename in cmd.filelist.files
- except UnicodeDecodeError:
- filename not in cmd.filelist.files
- else:
- # not all windows systems have a default FS encoding of cp1252
- if sys.platform == 'win32':
- # Latin-1 is similar to Windows-1252 however
- # on mbcs filesys it is not in latin-1 encoding
- fs_enc = sys.getfilesystemencoding()
- if fs_enc != 'mbcs':
- fs_enc = 'latin-1'
- filename = filename.decode(fs_enc)
+ # not all windows systems have a default FS encoding of cp1252
+ if sys.platform == 'win32':
+ # Latin-1 is similar to Windows-1252 however
+ # on mbcs filesys it is not in latin-1 encoding
+ fs_enc = sys.getfilesystemencoding()
+ if fs_enc != 'mbcs':
+ fs_enc = 'latin-1'
+ filename = filename.decode(fs_enc)
- assert filename in cmd.filelist.files
- else:
- # The Latin-1 filename should have been skipped
- filename = filename.decode('latin-1')
- filename not in cmd.filelist.files
+ assert filename in cmd.filelist.files
+ else:
+ # The Latin-1 filename should have been skipped
+ filename = filename.decode('latin-1')
+ filename not in cmd.filelist.files
def test_pyproject_toml_in_sdist(self, tmpdir):
"""
diff --git a/setuptools/tests/test_setopt.py b/setuptools/tests/test_setopt.py
index 1b038954..0163f9af 100644
--- a/setuptools/tests/test_setopt.py
+++ b/setuptools/tests/test_setopt.py
@@ -1,13 +1,7 @@
-# coding: utf-8
-
-from __future__ import unicode_literals
-
import io
-
-import six
+import configparser
from setuptools.command import setopt
-from setuptools.extern.six.moves import configparser
class TestEdit:
@@ -15,7 +9,7 @@ class TestEdit:
def parse_config(filename):
parser = configparser.ConfigParser()
with io.open(filename, encoding='utf-8') as reader:
- (parser.readfp if six.PY2 else parser.read_file)(reader)
+ parser.read_file(reader)
return parser
@staticmethod
diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py
index 08d263ae..42f8e18b 100644
--- a/setuptools/tests/test_setuptools.py
+++ b/setuptools/tests/test_setuptools.py
@@ -15,7 +15,6 @@ import setuptools
import setuptools.dist
import setuptools.depends as dep
from setuptools.depends import Require
-from setuptools.extern import six
def makeSetup(**args):
@@ -49,7 +48,7 @@ class TestDepends:
x = "test"
y = z
- fc = six.get_function_code(f1)
+ fc = f1.__code__
# unrecognized name
assert dep.extract_constant(fc, 'q', -1) is None
diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py
index 892fd120..180562e2 100644
--- a/setuptools/tests/test_test.py
+++ b/setuptools/tests/test_test.py
@@ -1,7 +1,3 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import unicode_literals
-
import mock
from distutils import log
import os
@@ -110,7 +106,6 @@ def test_tests_are_run_once(capfd):
with open('dummy/test_dummy.py', 'wt') as f:
f.write(DALS(
"""
- from __future__ import print_function
import unittest
class TestTest(unittest.TestCase):
def test_test(self):
diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py
index 555273ae..b555ce4f 100644
--- a/setuptools/tests/test_virtualenv.py
+++ b/setuptools/tests/test_virtualenv.py
@@ -13,17 +13,6 @@ from .test_easy_install import make_nspkg_sdist
@pytest.fixture(autouse=True)
-def disable_requires_python(monkeypatch):
- """
- Disable Requires-Python on Python 2.7
- """
- if sys.version_info > (3,):
- return
-
- monkeypatch.setenv('PIP_IGNORE_REQUIRES_PYTHON', 'true')
-
-
-@pytest.fixture(autouse=True)
def pytest_virtualenv_works(virtualenv):
"""
pytest_virtualenv may not work. if it doesn't, skip these
diff --git a/setuptools/tests/test_wheel.py b/setuptools/tests/test_wheel.py
index f72ccbbf..e56eac14 100644
--- a/setuptools/tests/test_wheel.py
+++ b/setuptools/tests/test_wheel.py
@@ -25,8 +25,6 @@ from .contexts import tempdir
from .files import build_files
from .textwrap import DALS
-__metaclass__ = type
-
WHEEL_INFO_TESTS = (
('invalid.whl', ValueError),
diff --git a/setuptools/tests/test_windows_wrappers.py b/setuptools/tests/test_windows_wrappers.py
index 2553394a..fa647de8 100644
--- a/setuptools/tests/test_windows_wrappers.py
+++ b/setuptools/tests/test_windows_wrappers.py
@@ -12,8 +12,6 @@ the script they are to wrap and with the same name as the script they
are to wrap.
"""
-from __future__ import absolute_import
-
import sys
import textwrap
import subprocess
diff --git a/setuptools/tests/text.py b/setuptools/tests/text.py
index ad2c6249..e05cc633 100644
--- a/setuptools/tests/text.py
+++ b/setuptools/tests/text.py
@@ -1,8 +1,3 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import unicode_literals
-
-
class Filenames:
unicode = 'smörbröd.py'
latin_1 = unicode.encode('latin-1')
diff --git a/setuptools/tests/textwrap.py b/setuptools/tests/textwrap.py
index 5cd9e5bc..5e39618d 100644
--- a/setuptools/tests/textwrap.py
+++ b/setuptools/tests/textwrap.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import
-
import textwrap