Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ markers = [
"integration: Full package build",
"setuptools: Tests setuptools integration",
"virtualenv: Needs a virtualenv",
"isolated: Needs an isolated virtualenv",
]


Expand Down
14 changes: 13 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,31 @@ def install(self, *args: str) -> None:


@pytest.fixture
def virtualenv(tmp_path: Path, pep518_wheelhouse: Path) -> Generator[VEnv, None, None]:
def isolated(tmp_path: Path, pep518_wheelhouse: Path) -> Generator[VEnv, None, None]:
path = tmp_path / "venv"
try:
yield VEnv(path, wheelhouse=pep518_wheelhouse)
finally:
shutil.rmtree(path)


@pytest.fixture
def virtualenv(tmp_path: Path) -> Generator[VEnv, None, None]:
path = tmp_path / "venv"
try:
yield VEnv(path)
finally:
shutil.rmtree(path)


def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
for item in items:
# Ensure all tests using virtualenv are marked as such
if "virtualenv" in getattr(item, "fixturenames", ()):
item.add_marker(pytest.mark.virtualenv)
if "isolated" in getattr(item, "fixturenames", ()):
item.add_marker(pytest.mark.virtualenv)
item.add_marker(pytest.mark.isolated)


def pytest_report_header() -> str:
Expand Down
24 changes: 10 additions & 14 deletions tests/test_pyproject_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def test_pep518_sdist():
@pytest.mark.parametrize(
"build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"]
)
def test_pep518_wheel(virtualenv, build_args, monkeypatch):
def test_pep518_wheel(isolated, build_args, monkeypatch):
dist = HELLO_PEP518 / "dist"
shutil.rmtree(dist, ignore_errors=True)
monkeypatch.chdir(HELLO_PEP518)
virtualenv.install("build[virtualenv]")
virtualenv.module(
isolated.install("build[virtualenv]")
isolated.module(
"build",
"--config-setting=logging.level=DEBUG",
*build_args,
Expand All @@ -95,27 +95,23 @@ def test_pep518_wheel(virtualenv, build_args, monkeypatch):
assert so_file.startswith("cmake_example")
print("SOFILE:", so_file)

virtualenv.install(wheel)
isolated.install(wheel)

version = virtualenv.execute(
"import cmake_example; print(cmake_example.__version__)"
)
version = isolated.execute("import cmake_example; print(cmake_example.__version__)")
assert version == "0.0.1"

add = virtualenv.execute("import cmake_example; print(cmake_example.add(1, 2))")
add = isolated.execute("import cmake_example; print(cmake_example.add(1, 2))")
assert add == "3"


@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.integration
def test_pep518_pip(virtualenv):
virtualenv.install("-v", HELLO_PEP518)
def test_pep518_pip(isolated):
isolated.install("-v", HELLO_PEP518)

version = virtualenv.execute(
"import cmake_example; print(cmake_example.__version__)"
)
version = isolated.execute("import cmake_example; print(cmake_example.__version__)")
assert version == "0.0.1"

add = virtualenv.execute("import cmake_example; print(cmake_example.add(1, 2))")
add = isolated.execute("import cmake_example; print(cmake_example.add(1, 2))")
assert add == "3"
22 changes: 10 additions & 12 deletions tests/test_setuptools_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
@pytest.mark.skipif(
sys.platform.startswith("cygwin"), reason="Cygwin fails here with ld errors"
)
def test_pep518_wheel(monkeypatch, virtualenv):
def test_pep518_wheel(monkeypatch, isolated):
dist = HELLO_PEP518 / "dist"
shutil.rmtree(dist, ignore_errors=True)
monkeypatch.chdir(HELLO_PEP518)
virtualenv.install("build[virtualenv]")
virtualenv.module("build", "--wheel")
isolated.install("build[virtualenv]")
isolated.module("build", "--wheel")
(wheel,) = dist.iterdir()
assert "cmake_example-0.0.1" in wheel.name
assert wheel.suffix == ".whl"
Expand All @@ -41,14 +41,12 @@ def test_pep518_wheel(monkeypatch, virtualenv):
assert so_file.startswith("cmake_example")
print("SOFILE:", so_file)

virtualenv.install(wheel)
isolated.install(wheel)

version = virtualenv.execute(
"import cmake_example; print(cmake_example.__version__)"
)
version = isolated.execute("import cmake_example; print(cmake_example.__version__)")
assert version == "0.0.1"

add = virtualenv.execute("import cmake_example; print(cmake_example.add(1, 2))")
add = isolated.execute("import cmake_example; print(cmake_example.add(1, 2))")
assert add == "3"


Expand All @@ -58,15 +56,15 @@ def test_pep518_wheel(monkeypatch, virtualenv):
@pytest.mark.skipif(
sys.platform.startswith("cygwin"), reason="Cygwin fails here with ld errors"
)
def test_pep518_pip(virtualenv):
virtualenv.install("-v", HELLO_PEP518)
def test_pep518_pip(isolated):
isolated.install("-v", HELLO_PEP518)

version = virtualenv.execute(
version = isolated.execute(
"import cmake_example; print(cmake_example.__version__)",
)
assert version == "0.0.1"

add = virtualenv.execute(
add = isolated.execute(
"import cmake_example; print(cmake_example.add(1, 2))",
)
assert add == "3"