Add test for RECORD population by make_wheel
"""Tests for wheel helper.
"""
+import csv
from email import message_from_string
from functools import partial
from zipfile import ZipFile
+from pip._vendor.six import ensure_text, iteritems
+
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from tests.lib.wheel import (
_default,
@@ -152,6 +155,47 @@ def test_make_wheel_basics(tmpdir):
}
+def test_make_wheel_default_record():
+ with make_wheel(
+ name="simple",
+ version="0.1.0",
+ extra_files={"simple/__init__.py": "a"},
+ extra_metadata_files={"LICENSE": "b"},
+ extra_data_files={"purelib/info.txt": "c"},
+ ).as_zipfile() as z:
+ record_bytes = z.read("simple-0.1.0.dist-info/RECORD")
+ record_text = ensure_text(record_bytes)
+ record_rows = list(csv.reader(record_text.splitlines()))
+ records = {
+ row[0]: row[1:] for row in record_rows
+ }
+
+ expected = {
+ "simple/__init__.py": [
+ "sha256=ypeBEsobvcr6wjGzmiPcTaeG7_gUfE5yuYB3ha_uSLs", "1"
+ ],
+ "simple-0.1.0.data/purelib/info.txt": [
+ "sha256=Ln0sA6lQeuJl7PW1NWiFpTOTogKdJBOUmXJloaJa78Y", "1"
+ ],
+ "simple-0.1.0.dist-info/LICENSE": [
+ "sha256=PiPoFgA5WUoziU9lZOGxNIu9egCI1CxKy3PurtWcAJ0", "1"
+ ],
+ "simple-0.1.0.dist-info/RECORD": ["", ""],
+ }
+ for name, values in iteritems(expected):
+ assert records[name] == values, name
+
+ # WHEEL and METADATA aren't constructed in a stable way, so just spot
+ # check.
+ expected_variable = {
+ "simple-0.1.0.dist-info/METADATA": "51",
+ "simple-0.1.0.dist-info/WHEEL": "104",
+ }
+ for name, length in iteritems(expected_variable):
+ assert records[name][0].startswith("sha256="), name
+ assert records[name][1] == length, name
+
+
def test_make_wheel_extra_files():
with make_wheel(
name="simple",
