diff options
Diffstat (limited to 'tests/cli')
| -rw-r--r-- | tests/cli/test_convert.py | 8 | ||||
| -rw-r--r-- | tests/cli/test_pack.py | 62 |
2 files changed, 43 insertions, 27 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 |
