summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2020-01-26 15:29:03 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2020-01-26 15:29:03 +0200
commite47da52e18c4a9473183ea95fb6d006bc831e806 (patch)
tree656f5871abb9d8f7fbbba22b37d90d78293619f4 /tests
parent244d9c2efaf55bf07f450df59d305b56c178738a (diff)
downloadwheel-git-e47da52e18c4a9473183ea95fb6d006bc831e806.tar.gz
Use the existing build tag in wheel pack unless overridden
Closes #323. Fixes #322.
Diffstat (limited to 'tests')
-rw-r--r--tests/cli/test_pack.py42
1 files changed, 31 insertions, 11 deletions
diff --git a/tests/cli/test_pack.py b/tests/cli/test_pack.py
index 818f817..cb3c58d 100644
--- a/tests/cli/test_pack.py
+++ b/tests/cli/test_pack.py
@@ -11,23 +11,43 @@ TESTWHEEL_PATH = os.path.join(THISDIR, '..', 'testdata', TESTWHEEL_NAME)
@pytest.mark.filterwarnings('error:Duplicate 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'))
+@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')
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)
+ 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_content = wheel_file_path.read_binary()
+ assert b'Build' not in wheel_file_content
+ wheel_file_content += b'Build: 3\n'
+ wheel_file_path.write(wheel_file_content)
+
+ pack(str(unpack_dir), str(tmpdir), build_tag_arg)
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)
+ 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')
assert new_record_lines == old_record_lines
+
+ expected_build_num = build_tag_arg or existing_build_tag
+ if expected_build_num:
+ assert ('Build: %s\n' % expected_build_num).encode() in new_wheel_file_content
+ else:
+ assert b'Build: ' not in new_wheel_file_content