Skip to content

Commit ccde78a

Browse files
committed
Add another fixture to consolidate multi-package installs
Signed-off-by: Cristian Le <[email protected]>
1 parent d06aa17 commit ccde78a

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

tests/conftest.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import sys
1010
import sysconfig
11+
from collections.abc import Iterable
1112
from importlib import metadata
1213
from pathlib import Path
1314
from typing import Any, Literal, overload
@@ -207,9 +208,12 @@ def source_date_epoch(self) -> str:
207208

208209

209210
def process_package(
210-
package: PackageInfo, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
211+
package: PackageInfo,
212+
tmp_path: Path,
213+
monkeypatch: pytest.MonkeyPatch,
214+
pkg_path: str = "pkg",
211215
) -> None:
212-
package_dir = tmp_path / "pkg"
216+
package_dir = tmp_path / pkg_path
213217
shutil.copytree(DIR / "packages" / package.name, package_dir)
214218
monkeypatch.chdir(package_dir)
215219

@@ -226,6 +230,22 @@ def package(
226230
return package
227231

228232

233+
@pytest.fixture
234+
def multiple_packages(
235+
request: pytest.FixtureRequest, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
236+
) -> list[PackageInfo]:
237+
package_names = request.param
238+
assert isinstance(package_names, Iterable)
239+
packages = []
240+
for pkg_name in package_names:
241+
pkg = PackageInfo(pkg_name)
242+
assert (DIR / "packages" / pkg.name).exists()
243+
process_package(pkg, tmp_path, monkeypatch, pkg_path=pkg.name)
244+
packages.append(pkg)
245+
monkeypatch.chdir(tmp_path)
246+
return packages
247+
248+
229249
@pytest.fixture
230250
def package_simple_pyproject_ext(
231251
tmp_path: Path, monkeypatch: pytest.MonkeyPatch

tests/test_editable.py

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77

88
import pytest
9-
from conftest import PackageInfo, process_package
109

1110

1211
@pytest.mark.compile
@@ -54,36 +53,22 @@ def test_navigate_editable(isolated, isolate, py_pkg):
5453
@pytest.mark.configure
5554
@pytest.mark.integration
5655
@pytest.mark.parametrize("isolate", {False}, indirect=True)
57-
def test_cython_pxd(monkeypatch, tmp_path, editable, isolated, isolate):
56+
@pytest.mark.parametrize(
57+
"multiple_packages",
58+
[["cython_pxd_editable/pkg1", "cython_pxd_editable/pkg2"]],
59+
indirect=True,
60+
)
61+
def test_cython_pxd(multiple_packages, editable, isolated, isolate):
5862
isolated.install("cython")
5963

60-
package1 = PackageInfo(
61-
"cython_pxd_editable/pkg1",
62-
)
63-
tmp_path1 = tmp_path / "pkg1"
64-
tmp_path1.mkdir()
65-
process_package(package1, tmp_path1, monkeypatch)
66-
67-
isolated.install(
68-
"-v",
69-
*isolate.flags,
70-
*editable.flags,
71-
".",
72-
)
73-
74-
package2 = PackageInfo(
75-
"cython_pxd_editable/pkg2",
76-
)
77-
tmp_path2 = tmp_path / "pkg2"
78-
tmp_path2.mkdir()
79-
process_package(package2, tmp_path2, monkeypatch)
80-
81-
isolated.install(
82-
"-v",
83-
*isolate.flags,
84-
*editable.flags,
85-
".",
86-
)
64+
# install the packages in order with one dependent on the other
65+
for package in multiple_packages:
66+
isolated.install(
67+
"-v",
68+
*isolate.flags,
69+
*editable.flags,
70+
package.name,
71+
)
8772

8873

8974
@pytest.mark.compile

0 commit comments

Comments
 (0)