Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Dec 20, 2022
1 parent ec8cc7f commit 3247759
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/masonry/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,31 @@ def test_build_editable_wheel() -> None:


def test_build_wheel_with_metadata_directory() -> None:
with temporary_directory() as metadata_tmp_dir, cwd(
os.path.join(fixtures, "complete")
):
pkg_dir = Path(fixtures) / "complete"

with temporary_directory() as metadata_tmp_dir, cwd(pkg_dir):
metadata_directory = api.prepare_metadata_for_build_wheel(metadata_tmp_dir)

with temporary_directory() as wheel_tmp_dir:
dist_info_path = Path(metadata_tmp_dir) / metadata_directory
open(dist_info_path / "CUSTOM", "w").close() # noqa: SIM115
filename = api.build_wheel(
wheel_tmp_dir, metadata_directory=str(dist_info_path)
)
wheel_pth = Path(wheel_tmp_dir) / filename

validate_wheel_contents(
name="my_package",
version="1.2.3",
path=str(os.path.join(wheel_tmp_dir, filename)),
path=str(wheel_pth),
files=["entry_points.txt"],
)

with zipfile.ZipFile(wheel_pth) as z:
namelist = z.namelist()

assert f"{metadata_directory}/CUSTOM" in namelist


def test_build_editable_wheel_with_metadata_directory() -> None:
pkg_dir = Path(fixtures) / "complete"
Expand All @@ -264,6 +272,7 @@ def test_build_editable_wheel_with_metadata_directory() -> None:

with temporary_directory() as wheel_tmp_dir:
dist_info_path = Path(metadata_tmp_dir) / metadata_directory
open(dist_info_path / "CUSTOM", "w").close() # noqa: SIM115
filename = api.build_editable(
wheel_tmp_dir, metadata_directory=str(dist_info_path)
)
Expand All @@ -281,3 +290,4 @@ def test_build_editable_wheel_with_metadata_directory() -> None:

assert "my_package.pth" in namelist
assert pkg_dir.as_posix() == z.read("my_package.pth").decode().strip()
assert f"{metadata_directory}/CUSTOM" in namelist

0 comments on commit 3247759

Please sign in to comment.