summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-12-24 01:27:26 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-12-24 01:45:01 +0200
commit5eb690c72ea59bc0f8a2fa34d3993ebe3dbe0d38 (patch)
treedff2a2103314f0fe6c5cc53b91a120f59edf78d3 /tests
parent64d0b8d779b5b41bacea2ef3b59f3e06f0e683ed (diff)
downloadwheel-git-5eb690c72ea59bc0f8a2fa34d3993ebe3dbe0d38.tar.gz
Adopted black and reformatted the codebase to match
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/test_convert.py8
-rw-r--r--tests/cli/test_pack.py62
-rw-r--r--tests/conftest.py52
-rw-r--r--tests/test_bdist_wheel.py173
-rw-r--r--tests/test_macosx_libfile.py149
-rw-r--r--tests/test_metadata.py63
-rw-r--r--tests/test_pkginfo.py8
-rw-r--r--tests/test_tagopt.py157
-rw-r--r--tests/test_wheelfile.py163
-rw-r--r--tests/testdata/abi3extension.dist/setup.py17
-rw-r--r--tests/testdata/commasinfilenames.dist/setup.py10
-rw-r--r--tests/testdata/complex-dist/setup.py39
-rw-r--r--tests/testdata/extension.dist/setup.py14
-rw-r--r--tests/testdata/headers.dist/setup.py11
-rw-r--r--tests/testdata/simple.dist/setup.py13
-rw-r--r--tests/testdata/unicode.dist/setup.py11
16 files changed, 572 insertions, 378 deletions
diff --git a/tests/cli/test_convert.py b/tests/cli/test_convert.py
index 7d711aa..82a75eb 100644
--- a/tests/cli/test_convert.py
+++ b/tests/cli/test_convert.py
@@ -7,7 +7,7 @@ from wheel.wheelfile import WHEEL_INFO_RE
def test_egg_re():
"""Make sure egg_info_re matches."""
- egg_names_path = os.path.join(os.path.dirname(__file__), 'eggnames.txt')
+ egg_names_path = os.path.join(os.path.dirname(__file__), "eggnames.txt")
with open(egg_names_path) as egg_names:
for line in egg_names:
line = line.strip()
@@ -20,5 +20,7 @@ def test_convert_egg(egg_paths, tmpdir):
wheel_names = [path.basename for path in tmpdir.listdir()]
assert len(wheel_names) == len(egg_paths)
assert all(WHEEL_INFO_RE.match(filename) for filename in wheel_names)
- assert all(re.match(r'^[\w\d.]+-\d\.\d-\w+\d+-[\w\d]+-[\w\d]+\.whl$', fname)
- for fname in wheel_names)
+ assert all(
+ re.match(r"^[\w\d.]+-\d\.\d-\w+\d+-[\w\d]+-[\w\d]+\.whl$", fname)
+ for fname in wheel_names
+ )
diff --git a/tests/cli/test_pack.py b/tests/cli/test_pack.py
index 3f689a4..8fa9008 100644
--- a/tests/cli/test_pack.py
+++ b/tests/cli/test_pack.py
@@ -7,31 +7,38 @@ import pytest
from wheel.cli.pack import pack
THISDIR = os.path.dirname(__file__)
-TESTWHEEL_NAME = 'test-1.0-py2.py3-none-any.whl'
-TESTWHEEL_PATH = os.path.join(THISDIR, '..', 'testdata', TESTWHEEL_NAME)
+TESTWHEEL_NAME = "test-1.0-py2.py3-none-any.whl"
+TESTWHEEL_PATH = os.path.join(THISDIR, "..", "testdata", TESTWHEEL_NAME)
-@pytest.mark.filterwarnings('error:Duplicate name')
-@pytest.mark.parametrize('build_tag_arg, existing_build_tag, filename', [
- (None, None, 'test-1.0-py2.py3-none-any.whl'),
- ('2b', None, 'test-1.0-2b-py2.py3-none-any.whl'),
- (None, '3', 'test-1.0-3-py2.py3-none-any.whl'),
- ('', '3', 'test-1.0-py2.py3-none-any.whl'),
-], ids=['nobuildnum', 'newbuildarg', 'oldbuildnum', 'erasebuildnum'])
+@pytest.mark.filterwarnings("error:Duplicate name")
+@pytest.mark.parametrize(
+ "build_tag_arg, existing_build_tag, filename",
+ [
+ (None, None, "test-1.0-py2.py3-none-any.whl"),
+ ("2b", None, "test-1.0-2b-py2.py3-none-any.whl"),
+ (None, "3", "test-1.0-3-py2.py3-none-any.whl"),
+ ("", "3", "test-1.0-py2.py3-none-any.whl"),
+ ],
+ ids=["nobuildnum", "newbuildarg", "oldbuildnum", "erasebuildnum"],
+)
def test_pack(tmpdir_factory, tmpdir, build_tag_arg, existing_build_tag, filename):
- unpack_dir = tmpdir_factory.mktemp('wheeldir')
+ unpack_dir = tmpdir_factory.mktemp("wheeldir")
with ZipFile(TESTWHEEL_PATH) as zf:
- old_record = zf.read('test-1.0.dist-info/RECORD')
- old_record_lines = sorted(line.rstrip() for line in old_record.split(b'\n')
- if line and not line.startswith(b'test-1.0.dist-info/WHEEL,'))
+ old_record = zf.read("test-1.0.dist-info/RECORD")
+ old_record_lines = sorted(
+ line.rstrip()
+ for line in old_record.split(b"\n")
+ if line and not line.startswith(b"test-1.0.dist-info/WHEEL,")
+ )
zf.extractall(str(unpack_dir))
if existing_build_tag:
# Add the build number to WHEEL
- wheel_file_path = unpack_dir.join('test-1.0.dist-info').join('WHEEL')
+ wheel_file_path = unpack_dir.join("test-1.0.dist-info").join("WHEEL")
wheel_file_content = wheel_file_path.read_binary()
- assert b'Build' not in wheel_file_content
- wheel_file_content += b'Build: 3\r\n'
+ assert b"Build" not in wheel_file_content
+ wheel_file_content += b"Build: 3\r\n"
wheel_file_path.write_binary(wheel_file_content)
pack(str(unpack_dir), str(tmpdir), build_tag_arg)
@@ -39,24 +46,31 @@ def test_pack(tmpdir_factory, tmpdir, build_tag_arg, existing_build_tag, filenam
assert new_wheel_path.isfile()
with ZipFile(str(new_wheel_path)) as zf:
- new_record = zf.read('test-1.0.dist-info/RECORD')
- new_record_lines = sorted(line.rstrip() for line in new_record.split(b'\n')
- if line and not line.startswith(b'test-1.0.dist-info/WHEEL,'))
+ new_record = zf.read("test-1.0.dist-info/RECORD")
+ new_record_lines = sorted(
+ line.rstrip()
+ for line in new_record.split(b"\n")
+ if line and not line.startswith(b"test-1.0.dist-info/WHEEL,")
+ )
- new_wheel_file_content = zf.read('test-1.0.dist-info/WHEEL')
+ new_wheel_file_content = zf.read("test-1.0.dist-info/WHEEL")
assert new_record_lines == old_record_lines
expected_build_num = build_tag_arg or existing_build_tag
- expected_wheel_content = dedent("""\
+ expected_wheel_content = dedent(
+ """\
Wheel-Version: 1.0
Generator: bdist_wheel (0.30.0)
Root-Is-Purelib: false
Tag: py2-none-any
Tag: py3-none-any
- """.replace('\n', '\r\n'))
+ """.replace(
+ "\n", "\r\n"
+ )
+ )
if expected_build_num:
- expected_wheel_content += 'Build: %s\r\n' % expected_build_num
+ expected_wheel_content += "Build: %s\r\n" % expected_build_num
- expected_wheel_content = expected_wheel_content.encode('ascii')
+ expected_wheel_content = expected_wheel_content.encode("ascii")
assert new_wheel_file_content == expected_wheel_content
diff --git a/tests/conftest.py b/tests/conftest.py
index 153954c..a7c5d61 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -9,35 +9,55 @@ import sys
import pytest
-@pytest.fixture(scope='session')
+@pytest.fixture(scope="session")
def wheels_and_eggs(tmpdir_factory):
"""Build wheels and eggs from test distributions."""
- test_distributions = ("complex-dist", "simple.dist", "headers.dist", "commasinfilenames.dist",
- "unicode.dist")
-
- if sys.platform != 'win32':
+ test_distributions = (
+ "complex-dist",
+ "simple.dist",
+ "headers.dist",
+ "commasinfilenames.dist",
+ "unicode.dist",
+ )
+
+ if sys.platform != "win32":
# ABI3 extensions don't really work on Windows
test_distributions += ("abi3extension.dist",)
pwd = os.path.abspath(os.curdir)
this_dir = os.path.dirname(__file__)
- build_dir = tmpdir_factory.mktemp('build')
- dist_dir = tmpdir_factory.mktemp('dist')
+ build_dir = tmpdir_factory.mktemp("build")
+ dist_dir = tmpdir_factory.mktemp("dist")
for dist in test_distributions:
- os.chdir(os.path.join(this_dir, 'testdata', dist))
- subprocess.check_call([sys.executable, 'setup.py',
- 'bdist_egg', '-b', str(build_dir), '-d', str(dist_dir),
- 'bdist_wheel', '-b', str(build_dir), '-d', str(dist_dir)])
+ os.chdir(os.path.join(this_dir, "testdata", dist))
+ subprocess.check_call(
+ [
+ sys.executable,
+ "setup.py",
+ "bdist_egg",
+ "-b",
+ str(build_dir),
+ "-d",
+ str(dist_dir),
+ "bdist_wheel",
+ "-b",
+ str(build_dir),
+ "-d",
+ str(dist_dir),
+ ]
+ )
os.chdir(pwd)
- return sorted(str(fname) for fname in dist_dir.listdir() if fname.ext in ('.whl', '.egg'))
+ return sorted(
+ str(fname) for fname in dist_dir.listdir() if fname.ext in (".whl", ".egg")
+ )
-@pytest.fixture(scope='session')
+@pytest.fixture(scope="session")
def wheel_paths(wheels_and_eggs):
- return [fname for fname in wheels_and_eggs if fname.endswith('.whl')]
+ return [fname for fname in wheels_and_eggs if fname.endswith(".whl")]
-@pytest.fixture(scope='session')
+@pytest.fixture(scope="session")
def egg_paths(wheels_and_eggs):
- return [fname for fname in wheels_and_eggs if fname.endswith('.egg')]
+ return [fname for fname in wheels_and_eggs if fname.endswith(".egg")]
diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py
index 6c47c47..67e5f92 100644
--- a/tests/test_bdist_wheel.py
+++ b/tests/test_bdist_wheel.py
@@ -11,117 +11,160 @@ from wheel.bdist_wheel import bdist_wheel
from wheel.wheelfile import WheelFile
DEFAULT_FILES = {
- 'dummy_dist-1.0.dist-info/top_level.txt',
- 'dummy_dist-1.0.dist-info/METADATA',
- 'dummy_dist-1.0.dist-info/WHEEL',
- 'dummy_dist-1.0.dist-info/RECORD'
+ "dummy_dist-1.0.dist-info/top_level.txt",
+ "dummy_dist-1.0.dist-info/METADATA",
+ "dummy_dist-1.0.dist-info/WHEEL",
+ "dummy_dist-1.0.dist-info/RECORD",
}
DEFAULT_LICENSE_FILES = {
- 'LICENSE', 'LICENSE.txt', 'LICENCE', 'LICENCE.txt', 'COPYING',
- 'COPYING.md', 'NOTICE', 'NOTICE.rst', 'AUTHORS', 'AUTHORS.txt'
+ "LICENSE",
+ "LICENSE.txt",
+ "LICENCE",
+ "LICENCE.txt",
+ "COPYING",
+ "COPYING.md",
+ "NOTICE",
+ "NOTICE.rst",
+ "AUTHORS",
+ "AUTHORS.txt",
}
OTHER_IGNORED_FILES = {
- 'LICENSE~', 'AUTHORS~',
+ "LICENSE~",
+ "AUTHORS~",
}
@pytest.fixture
def dummy_dist(tmpdir_factory):
- basedir = tmpdir_factory.mktemp('dummy_dist')
- basedir.join('setup.py').write("""\
+ basedir = tmpdir_factory.mktemp("dummy_dist")
+ basedir.join("setup.py").write(
+ """\
from setuptools import setup
setup(
name='dummy_dist',
version='1.0'
)
-""")
+"""
+ )
for fname in DEFAULT_LICENSE_FILES | OTHER_IGNORED_FILES:
- basedir.join(fname).write('')
+ basedir.join(fname).write("")
- basedir.join('licenses').mkdir().join('DUMMYFILE').write('')
+ basedir.join("licenses").mkdir().join("DUMMYFILE").write("")
return basedir
def test_no_scripts(wheel_paths):
"""Make sure entry point scripts are not generated."""
- path = next(path for path in wheel_paths if 'complex_dist' in path)
+ path = next(path for path in wheel_paths if "complex_dist" in path)
for entry in ZipFile(path).infolist():
- assert '.data/scripts/' not in entry.filename
+ assert ".data/scripts/" not in entry.filename
-@pytest.mark.skipif(sys.version_info < (3, 6),
- reason='Packaging unicode file names only works reliably on Python 3.6+')
+@pytest.mark.skipif(
+ sys.version_info < (3, 6),
+ reason="Packaging unicode file names only works reliably on Python 3.6+",
+)
def test_unicode_record(wheel_paths):
- path = next(path for path in wheel_paths if 'unicode.dist' in path)
+ path = next(path for path in wheel_paths if "unicode.dist" in path)
with ZipFile(path) as zf:
- record = zf.read('unicode.dist-0.1.dist-info/RECORD')
+ record = zf.read("unicode.dist-0.1.dist-info/RECORD")
- assert 'åäö_日本語.py'.encode() in record
+ assert "åäö_日本語.py".encode() in record
def test_licenses_default(dummy_dist, monkeypatch, tmpdir):
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal'])
- with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf:
- license_files = {'dummy_dist-1.0.dist-info/' + fname for fname in DEFAULT_LICENSE_FILES}
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]
+ )
+ with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
+ license_files = {
+ "dummy_dist-1.0.dist-info/" + fname for fname in DEFAULT_LICENSE_FILES
+ }
assert set(wf.namelist()) == DEFAULT_FILES | license_files
def test_licenses_deprecated(dummy_dist, monkeypatch, tmpdir):
- dummy_dist.join('setup.cfg').write('[metadata]\nlicense_file=licenses/DUMMYFILE')
+ dummy_dist.join("setup.cfg").write("[metadata]\nlicense_file=licenses/DUMMYFILE")
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal'])
- with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf:
- license_files = {'dummy_dist-1.0.dist-info/DUMMYFILE'}
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]
+ )
+ with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
+ license_files = {"dummy_dist-1.0.dist-info/DUMMYFILE"}
assert set(wf.namelist()) == DEFAULT_FILES | license_files
def test_licenses_override(dummy_dist, monkeypatch, tmpdir):
- dummy_dist.join('setup.cfg').write('[metadata]\nlicense_files=licenses/*\n LICENSE')
+ dummy_dist.join("setup.cfg").write(
+ "[metadata]\nlicense_files=licenses/*\n LICENSE"
+ )
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal'])
- with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf:
- license_files = {'dummy_dist-1.0.dist-info/' + fname for fname in {'DUMMYFILE', 'LICENSE'}}
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]
+ )
+ with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
+ license_files = {
+ "dummy_dist-1.0.dist-info/" + fname for fname in {"DUMMYFILE", "LICENSE"}
+ }
assert set(wf.namelist()) == DEFAULT_FILES | license_files
def test_licenses_disabled(dummy_dist, monkeypatch, tmpdir):
- dummy_dist.join('setup.cfg').write('[metadata]\nlicense_files=\n')
+ dummy_dist.join("setup.cfg").write("[metadata]\nlicense_files=\n")
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal'])
- with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf:
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]
+ )
+ with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
assert set(wf.namelist()) == DEFAULT_FILES
def test_build_number(dummy_dist, monkeypatch, tmpdir):
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal', '--build-number=2'])
- with WheelFile('dist/dummy_dist-1.0-2-py2.py3-none-any.whl') as wf:
+ subprocess.check_call(
+ [
+ sys.executable,
+ "setup.py",
+ "bdist_wheel",
+ "-b",
+ str(tmpdir),
+ "--universal",
+ "--build-number=2",
+ ]
+ )
+ with WheelFile("dist/dummy_dist-1.0-2-py2.py3-none-any.whl") as wf:
filenames = set(wf.namelist())
- assert 'dummy_dist-1.0.dist-info/RECORD' in filenames
- assert 'dummy_dist-1.0.dist-info/METADATA' in filenames
+ assert "dummy_dist-1.0.dist-info/RECORD" in filenames
+ assert "dummy_dist-1.0.dist-info/METADATA" in filenames
-@pytest.mark.skipif(sys.version_info[0] < 3, reason='The limited ABI only works on Python 3+')
+@pytest.mark.skipif(
+ sys.version_info[0] < 3, reason="The limited ABI only works on Python 3+"
+)
def test_limited_abi(monkeypatch, tmpdir):
"""Test that building a binary wheel with the limited ABI works."""
this_dir = os.path.dirname(__file__)
- source_dir = os.path.join(this_dir, 'testdata', 'extension.dist')
- build_dir = tmpdir.join('build')
- dist_dir = tmpdir.join('dist')
+ source_dir = os.path.join(this_dir, "testdata", "extension.dist")
+ build_dir = tmpdir.join("build")
+ dist_dir = tmpdir.join("dist")
monkeypatch.chdir(source_dir)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(build_dir),
- '-d', str(dist_dir)])
+ subprocess.check_call(
+ [
+ sys.executable,
+ "setup.py",
+ "bdist_wheel",
+ "-b",
+ str(build_dir),
+ "-d",
+ str(dist_dir),
+ ]
+ )
def test_build_from_readonly_tree(dummy_dist, monkeypatch, tmpdir):
- basedir = str(tmpdir.join('dummy'))
+ basedir = str(tmpdir.join("dummy"))
shutil.copytree(str(dummy_dist), basedir)
monkeypatch.chdir(basedir)
@@ -130,19 +173,31 @@ def test_build_from_readonly_tree(dummy_dist, monkeypatch, tmpdir):
for fname in files:
os.chmod(os.path.join(root, fname), stat.S_IREAD)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel'])
+ subprocess.check_call([sys.executable, "setup.py", "bdist_wheel"])
-@pytest.mark.parametrize('option, compress_type', list(bdist_wheel.supported_compressions.items()),
- ids=list(bdist_wheel.supported_compressions))
+@pytest.mark.parametrize(
+ "option, compress_type",
+ list(bdist_wheel.supported_compressions.items()),
+ ids=list(bdist_wheel.supported_compressions),
+)
def test_compression(dummy_dist, monkeypatch, tmpdir, option, compress_type):
monkeypatch.chdir(dummy_dist)
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '-b', str(tmpdir),
- '--universal', f'--compression={option}'])
- with WheelFile('dist/dummy_dist-1.0-py2.py3-none-any.whl') as wf:
+ subprocess.check_call(
+ [
+ sys.executable,
+ "setup.py",
+ "bdist_wheel",
+ "-b",
+ str(tmpdir),
+ "--universal",
+ f"--compression={option}",
+ ]
+ )
+ with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
filenames = set(wf.namelist())
- assert 'dummy_dist-1.0.dist-info/RECORD' in filenames
- assert 'dummy_dist-1.0.dist-info/METADATA' in filenames
+ assert "dummy_dist-1.0.dist-info/RECORD" in filenames
+ assert "dummy_dist-1.0.dist-info/METADATA" in filenames
for zinfo in wf.filelist:
assert zinfo.compress_type == compress_type
@@ -150,6 +205,6 @@ def test_compression(dummy_dist, monkeypatch, tmpdir, option, compress_type):
def test_wheelfile_line_endings(wheel_paths):
for path in wheel_paths:
with WheelFile(path) as wf:
- wheelfile = next(fn for fn in wf.filelist if fn.filename.endswith('WHEEL'))
+ wheelfile = next(fn for fn in wf.filelist if fn.filename.endswith("WHEEL"))
wheelfile_contents = wf.read(wheelfile)
- assert b'\r' not in wheelfile_contents
+ assert b"\r" not in wheelfile_contents
diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py
index 614e723..aad953c 100644
--- a/tests/test_macosx_libfile.py
+++ b/tests/test_macosx_libfile.py
@@ -8,8 +8,7 @@ from wheel.bdist_wheel import get_platform
def test_read_from_dylib():
dirname = os.path.dirname(__file__)
- dylib_dir = os.path.join(dirname, "testdata",
- "macosx_minimal_system_version")
+ dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
versions = [
("test_lib_10_6_fat.dylib", "10.6.0"),
("test_lib_10_10_fat.dylib", "10.10.0"),
@@ -31,12 +30,12 @@ def test_read_from_dylib():
)
str_ver = ".".join([str(x) for x in extracted])
assert str_ver == ver
- assert extract_macosx_min_system_version(
- os.path.join(dylib_dir, "test_lib.c")
- ) is None
- assert extract_macosx_min_system_version(
- os.path.join(dylib_dir, "libb.dylib")
- ) is None
+ assert (
+ extract_macosx_min_system_version(os.path.join(dylib_dir, "test_lib.c")) is None
+ )
+ assert (
+ extract_macosx_min_system_version(os.path.join(dylib_dir, "libb.dylib")) is None
+ )
def return_factory(return_val):
@@ -50,38 +49,60 @@ class TestGetPlatformMacosx:
def test_simple(self, monkeypatch):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-11.0-x86_64"))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-11.0-x86_64")
+ )
assert get_platform(dylib_dir) == "macosx_11_0_x86_64"
def test_version_bump(self, monkeypatch, capsys):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
assert get_platform(dylib_dir) == "macosx_11_0_x86_64"
captured = capsys.readouterr()
assert "[WARNING] This wheel needs a higher macOS version than" in captured.err
- def test_information_about_problematic_files_python_version(self, monkeypatch, capsys):
+ def test_information_about_problematic_files_python_version(
+ self, monkeypatch, capsys
+ ):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
captured = capsys.readouterr()
assert "[WARNING] This wheel needs a higher macOS version than" in captured.err
- assert "the version your Python interpreter is compiled against." in captured.err
+ assert (
+ "the version your Python interpreter is compiled against." in captured.err
+ )
assert "test_lib_10_10_fat.dylib" in captured.err
- def test_information_about_problematic_files_env_variable(self, monkeypatch, capsys):
+ def test_information_about_problematic_files_env_variable(
+ self, monkeypatch, capsys
+ ):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.8")
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
captured = capsys.readouterr()
assert "[WARNING] This wheel needs a higher macOS version than" in captured.err
@@ -91,10 +112,16 @@ class TestGetPlatformMacosx:
def test_bump_platform_tag_by_env_variable(self, monkeypatch, capsys):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_6_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_6_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_10_9_x86_64"
monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.10")
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
@@ -104,11 +131,26 @@ class TestGetPlatformMacosx:
def test_bugfix_release_platform_tag(self, monkeypatch, capsys):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_6_fat.dylib",
- "test_lib_10_10_10.dylib"])]
- ))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [
+ (
+ dylib_dir,
+ [],
+ [
+ "test_lib_10_6.dylib",
+ "test_lib_10_6_fat.dylib",
+ "test_lib_10_10_10.dylib",
+ ],
+ )
+ ]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
captured = capsys.readouterr()
assert "This wheel needs a higher macOS version than" in captured.err
@@ -120,32 +162,53 @@ class TestGetPlatformMacosx:
def test_warning_on_to_low_env_variable(self, monkeypatch, capsys):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.8")
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_6_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_6_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_10_9_x86_64"
captured = capsys.readouterr()
- assert "MACOSX_DEPLOYMENT_TARGET is set to a lower value (10.8) than the" in captured.err
+ assert (
+ "MACOSX_DEPLOYMENT_TARGET is set to a lower value (10.8) than the"
+ in captured.err
+ )
def test_get_platform_bigsur_env(self, monkeypatch):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64"))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")
+ )
monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "11")
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_11_0_x86_64"
def test_get_platform_bigsur_platform(self, monkeypatch):
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version")
- monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-11-x86_64"))
- monkeypatch.setattr(os, "walk", return_factory(
- [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
- ))
+ monkeypatch.setattr(
+ distutils.util, "get_platform", return_factory("macosx-11-x86_64")
+ )
+ monkeypatch.setattr(
+ os,
+ "walk",
+ return_factory(
+ [(dylib_dir, [], ["test_lib_10_6.dylib", "test_lib_10_10_fat.dylib"])]
+ ),
+ )
assert get_platform(dylib_dir) == "macosx_11_0_x86_64"
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
index 2e4f24c..3ecf64f 100644
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -3,30 +3,34 @@ from wheel.metadata import pkginfo_to_metadata
def test_pkginfo_to_metadata(tmpdir):
expected_metadata = [
- ('Metadata-Version', '2.1'),
- ('Name', 'spam'),
- ('Version', '0.1'),
- ('Requires-Dist', "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
- ('Requires-Dist', 'pywin32 ; sys_platform=="win32"'),
- ('Requires-Dist', 'foo @ http://host/foo.zip ; sys_platform=="win32"'),
- ('Provides-Extra', 'signatures'),
- ('Requires-Dist', 'pyxdg ; (sys_platform!="win32") and extra == \'signatures\''),
- ('Provides-Extra', 'empty_extra'),
- ('Provides-Extra', 'extra'),
- ('Requires-Dist', 'bar @ http://host/bar.zip ; extra == \'extra\''),
- ('Provides-Extra', 'faster-signatures'),
- ('Requires-Dist', "ed25519ll ; extra == 'faster-signatures'"),
- ('Provides-Extra', 'rest'),
- ('Requires-Dist', "docutils (>=0.8) ; extra == 'rest'"),
- ('Requires-Dist', "keyring ; extra == 'signatures'"),
- ('Requires-Dist', "keyrings.alt ; extra == 'signatures'"),
- ('Provides-Extra', 'test'),
- ('Requires-Dist', "pytest (>=3.0.0) ; extra == 'test'"),
- ('Requires-Dist', "pytest-cov ; extra == 'test'"),
+ ("Metadata-Version", "2.1"),
+ ("Name", "spam"),
+ ("Version", "0.1"),
+ ("Requires-Dist", "pip @ https://github.com/pypa/pip/archive/1.3.1.zip"),
+ ("Requires-Dist", 'pywin32 ; sys_platform=="win32"'),
+ ("Requires-Dist", 'foo @ http://host/foo.zip ; sys_platform=="win32"'),
+ ("Provides-Extra", "signatures"),
+ (
+ "Requires-Dist",
+ "pyxdg ; (sys_platform!=\"win32\") and extra == 'signatures'",
+ ),
+ ("Provides-Extra", "empty_extra"),
+ ("Provides-Extra", "extra"),
+ ("Requires-Dist", "bar @ http://host/bar.zip ; extra == 'extra'"),
+ ("Provides-Extra", "faster-signatures"),
+ ("Requires-Dist", "ed25519ll ; extra == 'faster-signatures'"),
+ ("Provides-Extra", "rest"),
+ ("Requires-Dist", "docutils (>=0.8) ; extra == 'rest'"),
+ ("Requires-Dist", "keyring ; extra == 'signatures'"),
+ ("Requires-Dist", "keyrings.alt ; extra == 'signatures'"),
+ ("Provides-Extra", "test"),
+ ("Requires-Dist", "pytest (>=3.0.0) ; extra == 'test'"),
+ ("Requires-Dist", "pytest-cov ; extra == 'test'"),
]
- pkg_info = tmpdir.join('PKG-INFO')
- pkg_info.write("""\
+ pkg_info = tmpdir.join("PKG-INFO")
+ pkg_info.write(
+ """\
Metadata-Version: 0.0
Name: spam
Version: 0.1
@@ -35,10 +39,12 @@ Provides-Extra: test
Provides-Extra: reST
Provides-Extra: signatures
Provides-Extra: Signatures
-Provides-Extra: faster-signatures""")
+Provides-Extra: faster-signatures"""
+ )
- egg_info_dir = tmpdir.ensure_dir('test.egg-info')
- egg_info_dir.join('requires.txt').write("""\
+ egg_info_dir = tmpdir.ensure_dir("test.egg-info")
+ egg_info_dir.join("requires.txt").write(
+ """\
pip@https://github.com/pypa/pip/archive/1.3.1.zip
[extra]
@@ -65,7 +71,10 @@ pyxdg
[test]
pytest>=3.0.0
-pytest-cov""")
+pytest-cov"""
+ )
- message = pkginfo_to_metadata(egg_info_path=str(egg_info_dir), pkginfo_path=str(pkg_info))
+ message = pkginfo_to_metadata(
+ egg_info_path=str(egg_info_dir), pkginfo_path=str(pkg_info)
+ )
assert message.items() == expected_metadata
diff --git a/tests/test_pkginfo.py b/tests/test_pkginfo.py
index a7e07a8..544f9d5 100644
--- a/tests/test_pkginfo.py
+++ b/tests/test_pkginfo.py
@@ -4,7 +4,9 @@ from wheel.pkginfo import write_pkg_info
def test_pkginfo_mangle_from(tmpdir):
- """Test that write_pkginfo() will not prepend a ">" to a line starting with "From"."""
+ """
+ Test that write_pkginfo() will not prepend a ">" to a line starting with "From".
+ """
metadata = """\
Metadata-Version: 2.1
Name: foo
@@ -17,6 +19,6 @@ Test
"""
message = Parser().parsestr(metadata)
- pkginfo_file = tmpdir.join('PKGINFO')
+ pkginfo_file = tmpdir.join("PKGINFO")
write_pkg_info(str(pkginfo_file), message)
- assert pkginfo_file.read_text('ascii') == metadata
+ assert pkginfo_file.read_text("ascii") == metadata
diff --git a/tests/test_tagopt.py b/tests/test_tagopt.py
index dd0c7a2..12be34b 100644
--- a/tests/test_tagopt.py
+++ b/tests/test_tagopt.py
@@ -25,176 +25,185 @@ EXT_MODULES = "ext_modules=[Extension('_test', sources=['test.c'])],"
@pytest.fixture
def temp_pkg(request, tmpdir):
- tmpdir.join('test.py').write('print("Hello, world")')
+ tmpdir.join("test.py").write('print("Hello, world")')
- ext = getattr(request, 'param', [False, ''])
+ ext = getattr(request, "param", [False, ""])
if ext[0]:
# if ext[1] is not '', it will write a bad header and fail to compile
- tmpdir.join('test.c').write('#include <std%sio.h>' % ext[1])
+ tmpdir.join("test.c").write("#include <std%sio.h>" % ext[1])
setup_py = SETUP_PY.format(ext_modules=EXT_MODULES)
else:
- setup_py = SETUP_PY.format(ext_modules='')
+ setup_py = SETUP_PY.format(ext_modules="")
- tmpdir.join('setup.py').write(setup_py)
+ tmpdir.join("setup.py").write(setup_py)
if ext[0]:
try:
subprocess.check_call(
- [sys.executable, 'setup.py', 'build_ext'], cwd=str(tmpdir))
+ [sys.executable, "setup.py", "build_ext"], cwd=str(tmpdir)
+ )
except subprocess.CalledProcessError:
- pytest.skip('Cannot compile C extensions')
+ pytest.skip("Cannot compile C extensions")
return tmpdir
-@pytest.mark.parametrize('temp_pkg', [[True, 'xxx']], indirect=['temp_pkg'])
+@pytest.mark.parametrize("temp_pkg", [[True, "xxx"]], indirect=["temp_pkg"])
def test_nocompile_skips(temp_pkg):
assert False # should have skipped with a "Cannot compile" message
def test_default_tag(temp_pkg):
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel'], cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename == f'Test-1.0-py{sys.version_info[0]}-none-any.whl'
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename == f"Test-1.0-py{sys.version_info[0]}-none-any.whl"
+ assert wheels[0].ext == ".whl"
def test_build_number(temp_pkg):
- subprocess.check_call([sys.executable, 'setup.py', 'bdist_wheel', '--build-number=1'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ subprocess.check_call(
+ [sys.executable, "setup.py", "bdist_wheel", "--build-number=1"],
+ cwd=str(temp_pkg),
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert (wheels[0].basename == f'Test-1.0-1-py{sys.version_info[0]}-none-any.whl')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename == f"Test-1.0-1-py{sys.version_info[0]}-none-any.whl"
+ assert wheels[0].ext == ".whl"
def test_explicit_tag(temp_pkg):
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel', '--python-tag=py32'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel", "--python-tag=py32"],
+ cwd=str(temp_pkg),
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py32-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py32-")
+ assert wheels[0].ext == ".whl"
def test_universal_tag(temp_pkg):
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel', '--universal'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel", "--universal"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py2.py3-")
+ assert wheels[0].ext == ".whl"
def test_universal_beats_explicit_tag(temp_pkg):
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel', '--universal', '--python-tag=py32'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel", "--universal", "--python-tag=py32"],
+ cwd=str(temp_pkg),
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py2.py3-")
+ assert wheels[0].ext == ".whl"
def test_universal_in_setup_cfg(temp_pkg):
- temp_pkg.join('setup.cfg').write('[bdist_wheel]\nuniversal=1')
+ temp_pkg.join("setup.cfg").write("[bdist_wheel]\nuniversal=1")
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py2.py3-")
+ assert wheels[0].ext == ".whl"
def test_pythontag_in_setup_cfg(temp_pkg):
- temp_pkg.join('setup.cfg').write('[bdist_wheel]\npython_tag=py32')
+ temp_pkg.join("setup.cfg").write("[bdist_wheel]\npython_tag=py32")
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py32-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py32-")
+ assert wheels[0].ext == ".whl"
def test_legacy_wheel_section_in_setup_cfg(temp_pkg):
- temp_pkg.join('setup.cfg').write('[wheel]\nuniversal=1')
+ temp_pkg.join("setup.cfg").write("[wheel]\nuniversal=1")
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.startswith('Test-1.0-py2.py3-')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.startswith("Test-1.0-py2.py3-")
+ assert wheels[0].ext == ".whl"
def test_plat_name_purepy(temp_pkg):
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel', '--plat-name=testplat.pure'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel", "--plat-name=testplat.pure"],
+ cwd=str(temp_pkg),
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.endswith('-testplat_pure.whl')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.endswith("-testplat_pure.whl")
+ assert wheels[0].ext == ".whl"
-@pytest.mark.parametrize('temp_pkg', [[True, '']], indirect=['temp_pkg'])
+@pytest.mark.parametrize("temp_pkg", [[True, ""]], indirect=["temp_pkg"])
def test_plat_name_ext(temp_pkg):
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel', '--plat-name=testplat.arch'],
- cwd=str(temp_pkg))
+ [sys.executable, "setup.py", "bdist_wheel", "--plat-name=testplat.arch"],
+ cwd=str(temp_pkg),
+ )
- dist_dir = temp_pkg.join('dist')
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.endswith('-testplat_arch.whl')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.endswith("-testplat_arch.whl")
+ assert wheels[0].ext == ".whl"
def test_plat_name_purepy_in_setupcfg(temp_pkg):
- temp_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.pure')
+ temp_pkg.join("setup.cfg").write("[bdist_wheel]\nplat_name=testplat.pure")
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel'],
- cwd=str(temp_pkg))
- dist_dir = temp_pkg.join('dist')
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.endswith('-testplat_pure.whl')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.endswith("-testplat_pure.whl")
+ assert wheels[0].ext == ".whl"
-@pytest.mark.parametrize('temp_pkg', [[True, '']], indirect=['temp_pkg'])
+@pytest.mark.parametrize("temp_pkg", [[True, ""]], indirect=["temp_pkg"])
def test_plat_name_ext_in_setupcfg(temp_pkg):
- temp_pkg.join('setup.cfg').write('[bdist_wheel]\nplat_name=testplat.arch')
+ temp_pkg.join("setup.cfg").write("[bdist_wheel]\nplat_name=testplat.arch")
subprocess.check_call(
- [sys.executable, 'setup.py', 'bdist_wheel'],
- cwd=str(temp_pkg))
+ [sys.executable, "setup.py", "bdist_wheel"], cwd=str(temp_pkg)
+ )
- dist_dir = temp_pkg.join('dist')
+ dist_dir = temp_pkg.join("dist")
assert dist_dir.check(dir=1)
wheels = dist_dir.listdir()
assert len(wheels) == 1
- assert wheels[0].basename.endswith('-testplat_arch.whl')
- assert wheels[0].ext == '.whl'
+ assert wheels[0].basename.endswith("-testplat_arch.whl")
+ assert wheels[0].ext == ".whl"
diff --git a/tests/test_wheelfile.py b/tests/test_wheelfile.py
index f6e6125..6b484ab 100644
--- a/tests/test_wheelfile.py
+++ b/tests/test_wheelfile.py
@@ -10,83 +10,99 @@ from wheel.wheelfile import WheelFile
@pytest.fixture
def wheel_path(tmpdir):
- return str(tmpdir.join('test-1.0-py2.py3-none-any.whl'))
+ return str(tmpdir.join("test-1.0-py2.py3-none-any.whl"))
def test_wheelfile_re(tmpdir):
# Regression test for #208
- path = tmpdir.join('foo-2-py3-none-any.whl')
- with WheelFile(str(path), 'w') as wf:
- assert wf.parsed_filename.group('namever') == 'foo-2'
-
-
-@pytest.mark.parametrize('filename', [
- 'test.whl',
- 'test-1.0.whl',
- 'test-1.0-py2.whl',
- 'test-1.0-py2-none.whl',
- 'test-1.0-py2-none-any'
-])
+ path = tmpdir.join("foo-2-py3-none-any.whl")
+ with WheelFile(str(path), "w") as wf:
+ assert wf.parsed_filename.group("namever") == "foo-2"
+
+
+@pytest.mark.parametrize(
+ "filename",
+ [
+ "test.whl",
+ "test-1.0.whl",
+ "test-1.0-py2.whl",
+ "test-1.0-py2-none.whl",
+ "test-1.0-py2-none-any",
+ ],
+)
def test_bad_wheel_filename(filename):
exc = pytest.raises(WheelError, WheelFile, filename)
- exc.match(f'^Bad wheel filename {filename!r}$')
+ exc.match(f"^Bad wheel filename {filename!r}$")
def test_missing_record(wheel_path):
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, w0rld!")\n'))
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, w0rld!")\n'))
exc = pytest.raises(WheelError, WheelFile, wheel_path)
exc.match("^Missing test-1.0.dist-info/RECORD file$")
def test_unsupported_hash_algorithm(wheel_path):
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, w0rld!")\n'))
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, w0rld!")\n'))
zf.writestr(
- 'test-1.0.dist-info/RECORD',
- as_bytes('hello/héllö.py,sha000=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25'))
+ "test-1.0.dist-info/RECORD",
+ as_bytes(
+ "hello/héllö.py,sha000=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25"
+ ),
+ )
exc = pytest.raises(WheelError, WheelFile, wheel_path)
exc.match("^Unsupported hash algorithm: sha000$")
-@pytest.mark.parametrize('algorithm, digest', [
- ('md5', '4J-scNa2qvSgy07rS4at-Q'),
- ('sha1', 'QjCnGu5Qucb6-vir1a6BVptvOA4')
-], ids=['md5', 'sha1'])
+@pytest.mark.parametrize(
+ "algorithm, digest",
+ [("md5", "4J-scNa2qvSgy07rS4at-Q"), ("sha1", "QjCnGu5Qucb6-vir1a6BVptvOA4")],
+ ids=["md5", "sha1"],
+)
def test_weak_hash_algorithm(wheel_path, algorithm, digest):
- hash_string = f'{algorithm}={digest}'
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, w0rld!")\n'))
- zf.writestr('test-1.0.dist-info/RECORD',
- as_bytes(f'hello/héllö.py,{hash_string},25'))
+ hash_string = f"{algorithm}={digest}"
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, w0rld!")\n'))
+ zf.writestr(
+ "test-1.0.dist-info/RECORD", as_bytes(f"hello/héllö.py,{hash_string},25")
+ )
exc = pytest.raises(WheelError, WheelFile, wheel_path)
exc.match(fr"^Weak hash algorithm \({algorithm}\) is not permitted by PEP 427$")
-@pytest.mark.parametrize('algorithm, digest', [
- ('sha256', 'bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo'),
- ('sha384', 'cDXriAy_7i02kBeDkN0m2RIDz85w6pwuHkt2PZ4VmT2PQc1TZs8Ebvf6eKDFcD_S'),
- ('sha512', 'kdX9CQlwNt4FfOpOKO_X0pn_v1opQuksE40SrWtMyP1NqooWVWpzCE3myZTfpy8g2azZON_'
- 'iLNpWVxTwuDWqBQ')
-], ids=['sha256', 'sha384', 'sha512'])
+@pytest.mark.parametrize(
+ "algorithm, digest",
+ [
+ ("sha256", "bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo"),
+ ("sha384", "cDXriAy_7i02kBeDkN0m2RIDz85w6pwuHkt2PZ4VmT2PQc1TZs8Ebvf6eKDFcD_S"),
+ (
+ "sha512",
+ "kdX9CQlwNt4FfOpOKO_X0pn_v1opQuksE40SrWtMyP1NqooWVWpzCE3myZTfpy8g2azZON_"
+ "iLNpWVxTwuDWqBQ",
+ ),
+ ],
+ ids=["sha256", "sha384", "sha512"],
+)
def test_testzip(wheel_path, algorithm, digest):
- hash_string = f'{algorithm}={digest}'
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, world!")\n'))
- zf.writestr('test-1.0.dist-info/RECORD',
- as_bytes(f'hello/héllö.py,{hash_string},25'))
+ hash_string = f"{algorithm}={digest}"
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, world!")\n'))
+ zf.writestr(
+ "test-1.0.dist-info/RECORD", as_bytes(f"hello/héllö.py,{hash_string},25")
+ )
with WheelFile(wheel_path) as wf:
wf.testzip()
def test_testzip_missing_hash(wheel_path):
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, world!")\n'))
- zf.writestr('test-1.0.dist-info/RECORD', '')
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, world!")\n'))
+ zf.writestr("test-1.0.dist-info/RECORD", "")
with WheelFile(wheel_path) as wf:
exc = pytest.raises(WheelError, wf.testzip)
@@ -94,11 +110,14 @@ def test_testzip_missing_hash(wheel_path):
def test_testzip_bad_hash(wheel_path):
- with ZipFile(wheel_path, 'w') as zf:
- zf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, w0rld!")\n'))
+ with ZipFile(wheel_path, "w") as zf:
+ zf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, w0rld!")\n'))
zf.writestr(
- 'test-1.0.dist-info/RECORD',
- as_bytes('hello/héllö.py,sha256=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25'))
+ "test-1.0.dist-info/RECORD",
+ as_bytes(
+ "hello/héllö.py,sha256=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25"
+ ),
+ )
with WheelFile(wheel_path) as wf:
exc = pytest.raises(WheelError, wf.testzip)
@@ -106,66 +125,68 @@ def test_testzip_bad_hash(wheel_path):
def test_write_str(wheel_path):
- with WheelFile(wheel_path, 'w') as wf:
- wf.writestr(native('hello/héllö.py'), as_bytes('print("Héllö, world!")\n'))
- wf.writestr(native('hello/h,ll,.py'), as_bytes('print("Héllö, world!")\n'))
+ with WheelFile(wheel_path, "w") as wf:
+ wf.writestr(native("hello/héllö.py"), as_bytes('print("Héllö, world!")\n'))
+ wf.writestr(native("hello/h,ll,.py"), as_bytes('print("Héllö, world!")\n'))
- with ZipFile(wheel_path, 'r') as zf:
+ with ZipFile(wheel_path, "r") as zf:
infolist = zf.infolist()
assert len(infolist) == 3
- assert infolist[0].filename == native('hello/héllö.py')
+ assert infolist[0].filename == native("hello/héllö.py")
assert infolist[0].file_size == 25
- assert infolist[1].filename == native('hello/h,ll,.py')
+ assert infolist[1].filename == native("hello/h,ll,.py")
assert infolist[1].file_size == 25
- assert infolist[2].filename == 'test-1.0.dist-info/RECORD'
+ assert infolist[2].filename == "test-1.0.dist-info/RECORD"
- record = zf.read('test-1.0.dist-info/RECORD')
+ record = zf.read("test-1.0.dist-info/RECORD")
assert record == as_bytes(
- 'hello/héllö.py,sha256=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25\n'
+ "hello/héllö.py,sha256=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25\n"
'"hello/h,ll,.py",sha256=bv-QV3RciQC2v3zL8Uvhd_arp40J5A9xmyubN34OVwo,25\n'
- 'test-1.0.dist-info/RECORD,,\n')
+ "test-1.0.dist-info/RECORD,,\n"
+ )
def test_timestamp(tmpdir_factory, wheel_path, monkeypatch):
# An environment variable can be used to influence the timestamp on
# TarInfo objects inside the zip. See issue #143.
- build_dir = tmpdir_factory.mktemp('build')
- for filename in ('one', 'two', 'three'):
- build_dir.join(filename).write(filename + '\n')
+ build_dir = tmpdir_factory.mktemp("build")
+ for filename in ("one", "two", "three"):
+ build_dir.join(filename).write(filename + "\n")
# The earliest date representable in TarInfos, 1980-01-01
- monkeypatch.setenv(native('SOURCE_DATE_EPOCH'), native('315576060'))
+ monkeypatch.setenv(native("SOURCE_DATE_EPOCH"), native("315576060"))
- with WheelFile(wheel_path, 'w') as wf:
+ with WheelFile(wheel_path, "w") as wf:
wf.write_files(str(build_dir))
- with ZipFile(wheel_path, 'r') as zf:
+ with ZipFile(wheel_path, "r") as zf:
for info in zf.infolist():
assert info.date_time[:3] == (1980, 1, 1)
assert info.compress_type == ZIP_DEFLATED
-@pytest.mark.skipif(sys.platform == 'win32',
- reason='Windows does not support UNIX-like permissions')
+@pytest.mark.skipif(
+ sys.platform == "win32", reason="Windows does not support UNIX-like permissions"
+)
def test_attributes(tmpdir_factory, wheel_path):
# With the change from ZipFile.write() to .writestr(), we need to manually
# set member attributes.
- build_dir = tmpdir_factory.mktemp('build')
- files = (('foo', 0o644), ('bar', 0o755))
+ build_dir = tmpdir_factory.mktemp("build")
+ files = (("foo", 0o644), ("bar", 0o755))
for filename, mode in files:
path = build_dir.join(filename)
- path.write(filename + '\n')
+ path.write(filename + "\n")
path.chmod(mode)
- with WheelFile(wheel_path, 'w') as wf:
+ with WheelFile(wheel_path, "w") as wf:
wf.write_files(str(build_dir))
- with ZipFile(wheel_path, 'r') as zf:
+ with ZipFile(wheel_path, "r") as zf:
for filename, mode in files:
info = zf.getinfo(filename)
assert info.external_attr == (mode | 0o100000) << 16
assert info.compress_type == ZIP_DEFLATED
- info = zf.getinfo('test-1.0.dist-info/RECORD')
+ info = zf.getinfo("test-1.0.dist-info/RECORD")
permissions = (info.external_attr >> 16) & 0o777
assert permissions == 0o664
diff --git a/tests/testdata/abi3extension.dist/setup.py b/tests/testdata/abi3extension.dist/setup.py
index e9a08df..10127da 100644
--- a/tests/testdata/abi3extension.dist/setup.py
+++ b/tests/testdata/abi3extension.dist/setup.py
@@ -1,11 +1,10 @@
from setuptools import setup, Extension
-setup(name='extension.dist',
- version='0.1',
- description='A testing distribution \N{SNOWMAN}',
- ext_modules=[
- Extension(name='extension',
- sources=['extension.c'],
- py_limited_api=True)
- ],
- )
+setup(
+ name="extension.dist",
+ version="0.1",
+ description="A testing distribution \N{SNOWMAN}",
+ ext_modules=[
+ Extension(name="extension", sources=["extension.c"], py_limited_api=True)
+ ],
+)
diff --git a/tests/testdata/commasinfilenames.dist/setup.py b/tests/testdata/commasinfilenames.dist/setup.py
index 8cf9e4e..b24e0cb 100644
--- a/tests/testdata/commasinfilenames.dist/setup.py
+++ b/tests/testdata/commasinfilenames.dist/setup.py
@@ -1,12 +1,10 @@
from setuptools import setup
setup(
- name='testrepo',
- version='0.1',
+ name="testrepo",
+ version="0.1",
packages=["mypackage"],
- description='A test package with commas in file names',
+ description="A test package with commas in file names",
include_package_data=True,
- package_data={
- "mypackage.data": ["*"]
- },
+ package_data={"mypackage.data": ["*"]},
)
diff --git a/tests/testdata/complex-dist/setup.py b/tests/testdata/complex-dist/setup.py
index 632ae3f..70d85df 100644
--- a/tests/testdata/complex-dist/setup.py
+++ b/tests/testdata/complex-dist/setup.py
@@ -1,21 +1,22 @@
from setuptools import setup
-setup(name='complex-dist',
- version='0.1',
- description='Another testing distribution \N{SNOWMAN}',
- long_description='Another testing distribution \N{SNOWMAN}',
- author="Illustrious Author",
- author_email="illustrious@example.org",
- url="http://example.org/exemplary",
- packages=['complexdist'],
- setup_requires=["wheel", "setuptools"],
- install_requires=["quux", "splort"],
- extras_require={'simple': ['simple.dist']},
- tests_require=["foo", "bar>=10.0.0"],
- entry_points={
- 'console_scripts': [
- 'complex-dist=complexdist:main',
- 'complex-dist2=complexdist:main',
- ],
- },
- )
+setup(
+ name="complex-dist",
+ version="0.1",
+ description="Another testing distribution \N{SNOWMAN}",
+ long_description="Another testing distribution \N{SNOWMAN}",
+ author="Illustrious Author",
+ author_email="illustrious@example.org",
+ url="http://example.org/exemplary",
+ packages=["complexdist"],
+ setup_requires=["wheel", "setuptools"],
+ install_requires=["quux", "splort"],
+ extras_require={"simple": ["simple.dist"]},
+ tests_require=["foo", "bar>=10.0.0"],
+ entry_points={
+ "console_scripts": [
+ "complex-dist=complexdist:main",
+ "complex-dist2=complexdist:main",
+ ],
+ },
+)
diff --git a/tests/testdata/extension.dist/setup.py b/tests/testdata/extension.dist/setup.py
index c9bf948..fc4042b 100644
--- a/tests/testdata/extension.dist/setup.py
+++ b/tests/testdata/extension.dist/setup.py
@@ -1,10 +1,8 @@
from setuptools import setup, Extension
-setup(name='extension.dist',
- version='0.1',
- description='A testing distribution \N{SNOWMAN}',
- ext_modules=[
- Extension(name='extension',
- sources=['extension.c'])
- ],
- )
+setup(
+ name="extension.dist",
+ version="0.1",
+ description="A testing distribution \N{SNOWMAN}",
+ ext_modules=[Extension(name="extension", sources=["extension.c"])],
+)
diff --git a/tests/testdata/headers.dist/setup.py b/tests/testdata/headers.dist/setup.py
index 2c7d7ea..d9d8adb 100644
--- a/tests/testdata/headers.dist/setup.py
+++ b/tests/testdata/headers.dist/setup.py
@@ -1,7 +1,8 @@
from setuptools import setup
-setup(name='headers.dist',
- version='0.1',
- description='A distribution with headers',
- headers=['header.h']
- )
+setup(
+ name="headers.dist",
+ version="0.1",
+ description="A distribution with headers",
+ headers=["header.h"],
+)
diff --git a/tests/testdata/simple.dist/setup.py b/tests/testdata/simple.dist/setup.py
index 81b26cd..3c7da87 100644
--- a/tests/testdata/simple.dist/setup.py
+++ b/tests/testdata/simple.dist/setup.py
@@ -1,8 +1,9 @@
from setuptools import setup
-setup(name='simple.dist',
- version='0.1',
- description='A testing distribution \N{SNOWMAN}',
- packages=['simpledist'],
- extras_require={'voting': ['beaglevote']},
- )
+setup(
+ name="simple.dist",
+ version="0.1",
+ description="A testing distribution \N{SNOWMAN}",
+ packages=["simpledist"],
+ extras_require={"voting": ["beaglevote"]},
+)
diff --git a/tests/testdata/unicode.dist/setup.py b/tests/testdata/unicode.dist/setup.py
index 221088e..606f42a 100644
--- a/tests/testdata/unicode.dist/setup.py
+++ b/tests/testdata/unicode.dist/setup.py
@@ -1,7 +1,8 @@
from setuptools import setup
-setup(name='unicode.dist',
- version='0.1',
- description='A testing distribution \N{SNOWMAN}',
- packages=['unicodedist']
- )
+setup(
+ name="unicode.dist",
+ version="0.1",
+ description="A testing distribution \N{SNOWMAN}",
+ packages=["unicodedist"],
+)