Skip to content

Commit

Permalink
unit test for csv RECORD file
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jun 12, 2022
1 parent fe05323 commit 4ed49b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
11 changes: 7 additions & 4 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import csv
import json
import re
import shutil
Expand Down Expand Up @@ -400,12 +401,14 @@ def verify_installed_distribution(

if url_reference is not None:
record_file = distribution._path.joinpath("RECORD")
with open(record_file, encoding="utf-8", newline="") as f:
reader = csv.reader(f)
rows = list(reader)
assert all(len(row) == 3 for row in rows)
record_entries = {row[0] for row in rows}
direct_url_entry = direct_url_file.relative_to(record_file.parent.parent)
assert direct_url_file.exists()
assert str(direct_url_entry) in {
row.split(",")[0]
for row in record_file.read_text(encoding="utf-8").splitlines()
}
assert str(direct_url_entry) in record_entries
assert json.loads(direct_url_file.read_text(encoding="utf-8")) == url_reference
else:
assert not direct_url_file.exists()
Expand Down
24 changes: 15 additions & 9 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import csv
import json
import os
import shutil
Expand Down Expand Up @@ -158,17 +159,22 @@ def test_builder_installs_proper_files_for_standard_packages(
"""
assert metadata == dist_info.joinpath("METADATA").read_text(encoding="utf-8")

records = dist_info.joinpath("RECORD").read_text()
with open(dist_info.joinpath("RECORD"), encoding="utf-8", newline="") as f:
reader = csv.reader(f)
records = list(reader)

assert all(len(row) == 3 for row in records)
record_entries = {row[0] for row in records}
pth_file = "simple_project.pth"
assert tmp_venv.site_packages.exists(pth_file)
assert str(tmp_venv.site_packages.find(pth_file)[0]) in records
assert str(tmp_venv._bin_dir.joinpath("foo")) in records
assert str(tmp_venv._bin_dir.joinpath("baz")) in records
assert str(dist_info.joinpath("METADATA")) in records
assert str(dist_info.joinpath("INSTALLER")) in records
assert str(dist_info.joinpath("entry_points.txt")) in records
assert str(dist_info.joinpath("RECORD")) in records
assert str(dist_info.joinpath("direct_url.json")) in records
assert str(tmp_venv.site_packages.find(pth_file)[0]) in record_entries
assert str(tmp_venv._bin_dir.joinpath("foo")) in record_entries
assert str(tmp_venv._bin_dir.joinpath("baz")) in record_entries
assert str(dist_info.joinpath("METADATA")) in record_entries
assert str(dist_info.joinpath("INSTALLER")) in record_entries
assert str(dist_info.joinpath("entry_points.txt")) in record_entries
assert str(dist_info.joinpath("RECORD")) in record_entries
assert str(dist_info.joinpath("direct_url.json")) in record_entries

baz_script = f"""\
#!{tmp_venv.python}
Expand Down

0 comments on commit 4ed49b7

Please sign in to comment.