Skip to content

Commit

Permalink
test(build): order in RECORD files and archives should be determinist…
Browse files Browse the repository at this point in the history
…ic due to #545
  • Loading branch information
radoering committed Mar 11, 2023
1 parent 7976f68 commit b1d3604
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/masonry/builders/test_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def test_wheel_c_extension(project: str, exptected_c_dir: str) -> None:
assert re.search(r"\s+extended/extended.*\.(so|pyd)", record) is not None

# Files in RECORD should match files in wheel.
zip_files = sorted(zipf.namelist())
assert zip_files == sorted(record_files)
assert zipf.namelist() == record_files
assert len(set(record_files)) == len(record_files)


Expand Down Expand Up @@ -125,17 +124,17 @@ def test_complete(no_vcs: bool) -> None:
"my_package/sub_pkg1/__init__.py",
"my_package/sub_pkg2/__init__.py",
"my_package/sub_pkg2/data2/data.json",
"my_package-1.2.3.data/scripts/script.sh",
"my_package/sub_pkg3/foo.py",
"my_package-1.2.3.data/scripts/script.sh",
"my_package-1.2.3.dist-info/entry_points.txt",
"my_package-1.2.3.dist-info/LICENSE",
"my_package-1.2.3.dist-info/WHEEL",
"my_package-1.2.3.dist-info/METADATA",
"my_package-1.2.3.dist-info/WHEEL",
"my_package-1.2.3.dist-info/RECORD",
]

with zipfile.ZipFile(str(whl)) as zipf:
assert sorted(zipf.namelist()) == sorted(expected_name_list)
assert zipf.namelist() == expected_name_list
assert (
"Hello World"
in zipf.read("my_package-1.2.3.data/scripts/script.sh").decode()
Expand Down Expand Up @@ -208,12 +207,11 @@ def test_complete(no_vcs: bool) -> None:
)
actual_records = zipf.read("my_package-1.2.3.dist-info/RECORD").decode()

# For some reason, the ordering of the files and the SHA hashes
# vary per operating systems and Python versions.
# The SHA hashes vary per operating systems.
# So instead of 1:1 assertion, let's do a bit clunkier one:
actual_files = [row[0] for row in csv.reader(actual_records.splitlines())]

assert sorted(actual_files) == sorted(expected_name_list)
assert actual_files == expected_name_list


def test_module_src() -> None:
Expand Down

0 comments on commit b1d3604

Please sign in to comment.