summaryrefslogtreecommitdiff
path: root/tests/cli/test_pack.py
blob: b90687e4402f3624dcf31d49252901c9459c9927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from zipfile import ZipFile

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)


@pytest.mark.parametrize('build_number, filename', [
    (None, 'test-1.0-py2.py3-none-any.whl'),
    ('2b', 'test-1.0-2b-py2.py3-none-any.whl')
], ids=['nobuildnum', 'buildnum'])
def test_pack(tmpdir_factory, tmpdir, build_number, filename):
    unpack_dir = str(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)
        zf.extractall(unpack_dir)

    pack(unpack_dir, str(tmpdir), build_number)
    new_wheel_path = tmpdir.join(filename)
    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)

    assert new_record_lines == old_record_lines