aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
authorHugo <hugovk@users.noreply.github.com>2020-01-08 19:10:11 +0200
committerHugo <hugovk@users.noreply.github.com>2020-01-08 19:10:11 +0200
commit796abd8dbec884cedf326cb5f85512a5d5648c4e (patch)
treecacbbdc28822b519f87b679a8262687421d13c01 /setuptools/tests
parent7e97def47723303fafabe48b22168bbc11bb4821 (diff)
downloadexternal_python_setuptools-796abd8dbec884cedf326cb5f85512a5d5648c4e.tar.gz
external_python_setuptools-796abd8dbec884cedf326cb5f85512a5d5648c4e.tar.bz2
external_python_setuptools-796abd8dbec884cedf326cb5f85512a5d5648c4e.zip
Fix for Python 4: replace unsafe six.PY3 with PY2
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/test_develop.py4
-rw-r--r--setuptools/tests/test_sdist.py32
-rw-r--r--setuptools/tests/test_setopt.py2
3 files changed, 19 insertions, 19 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py
index 00d4bd9a..792975fd 100644
--- a/setuptools/tests/test_develop.py
+++ b/setuptools/tests/test_develop.py
@@ -95,7 +95,7 @@ class TestDevelop:
with io.open(fn) as init_file:
init = init_file.read().strip()
- expected = 'print("foo")' if six.PY3 else 'print "foo"'
+ expected = 'print "foo"' if six.PY2 else 'print("foo")'
assert init == expected
def test_console_scripts(self, tmpdir):
@@ -161,7 +161,7 @@ class TestNamespaces:
reason="https://github.com/pypa/setuptools/issues/851",
)
@pytest.mark.skipif(
- platform.python_implementation() == 'PyPy' and six.PY3,
+ platform.python_implementation() == 'PyPy' and not six.PY2,
reason="https://github.com/pypa/setuptools/issues/1202",
)
def test_namespace_package_importable(self, tmpdir):
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
index 8538dd24..0bea53df 100644
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -51,7 +51,7 @@ def quiet():
# Convert to POSIX path
def posix(path):
- if six.PY3 and not isinstance(path, str):
+ if not six.PY2 and not isinstance(path, str):
return path.replace(os.sep.encode('ascii'), b'/')
else:
return path.replace(os.sep, '/')
@@ -329,7 +329,7 @@ class TestSdistTest:
cmd.read_manifest()
# The filelist should contain the UTF-8 filename
- if six.PY3:
+ if not six.PY2:
filename = filename.decode('utf-8')
assert filename in cmd.filelist.files
@@ -383,7 +383,7 @@ class TestSdistTest:
if sys.platform == 'darwin':
filename = decompose(filename)
- if six.PY3:
+ if not six.PY2:
fs_enc = sys.getfilesystemencoding()
if sys.platform == 'win32':
@@ -425,7 +425,19 @@ class TestSdistTest:
with quiet():
cmd.run()
- if six.PY3:
+ 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
@@ -440,18 +452,6 @@ class TestSdistTest:
# The Latin-1 filename should have been skipped
filename = filename.decode('latin-1')
filename not in cmd.filelist.files
- else:
- # 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
def test_pyproject_toml_in_sdist(self, tmpdir):
"""
diff --git a/setuptools/tests/test_setopt.py b/setuptools/tests/test_setopt.py
index 3fb04fb4..1b038954 100644
--- a/setuptools/tests/test_setopt.py
+++ b/setuptools/tests/test_setopt.py
@@ -15,7 +15,7 @@ class TestEdit:
def parse_config(filename):
parser = configparser.ConfigParser()
with io.open(filename, encoding='utf-8') as reader:
- (parser.read_file if six.PY3 else parser.readfp)(reader)
+ (parser.readfp if six.PY2 else parser.read_file)(reader)
return parser
@staticmethod