Skip to content

Commit

Permalink
test: reorganize pixi build tests (#2639)
Browse files Browse the repository at this point in the history
- move test data to common directory
- move helper functions to fixtures
  • Loading branch information
Hofer-Julian authored Dec 4, 2024
1 parent d4d3c6d commit 35b7f7d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
9 changes: 7 additions & 2 deletions tests/integration_python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ def tmp_pixi_workspace(tmp_path: Path) -> Path:


@pytest.fixture
def channels() -> Path:
return Path(__file__).parent.parent.joinpath("data", "channels", "channels").resolve()
def test_data() -> Path:
return Path(__file__).parents[1].joinpath("data").resolve()


@pytest.fixture
def channels(test_data: Path) -> Path:
return test_data.joinpath("channels", "channels")


@pytest.fixture
Expand Down
18 changes: 18 additions & 0 deletions tests/integration_python/pixi_build/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pathlib import Path
import pytest


@pytest.fixture
def build_data(test_data: Path) -> Path:
"""
Returns the pixi build test data
"""
return test_data.joinpath("pixi_build")


@pytest.fixture
def examples_dir() -> Path:
"""
Returns the path to the examples directory in the root of the repository
"""
return Path(__file__).parents[3].joinpath("examples").resolve()
31 changes: 8 additions & 23 deletions tests/integration_python/pixi_build/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,11 @@
from ..common import verify_cli_command


def get_data_dir(backend: str | None = None) -> Path:
"""
Returns the path to the test-data directory next to the tests
"""
if backend is None:
return Path(__file__).parent / "test-data"
else:
return Path(__file__).parent / "test-data" / backend


def examples_dir() -> Path:
"""
Returns the path to the examples directory in the root of the repository
"""
return (Path(__file__).parent / "../../../examples").resolve()


def test_build_conda_package(pixi: Path, tmp_pixi_workspace: Path) -> None:
def test_build_conda_package(pixi: Path, examples_dir: Path, tmp_pixi_workspace: Path) -> None:
"""
This one tries to build the example flask hello world project
"""
pyproject = examples_dir() / "flask-hello-world-pyproject"
pyproject = examples_dir / "flask-hello-world-pyproject"
shutil.copytree(pyproject, tmp_pixi_workspace / "pyproject")

manifest_path = tmp_pixi_workspace / "pyproject" / "pyproject.toml"
Expand All @@ -53,8 +36,10 @@ def test_build_conda_package(pixi: Path, tmp_pixi_workspace: Path) -> None:
assert package_to_be_built.exists()


def test_build_using_rattler_build_backend(pixi: Path, tmp_pixi_workspace: Path) -> None:
test_data = get_data_dir("rattler-build-backend")
def test_build_using_rattler_build_backend(
pixi: Path, build_data: Path, tmp_pixi_workspace: Path
) -> None:
test_data = build_data.joinpath("rattler-build-backend")
shutil.copytree(test_data / "pixi", tmp_pixi_workspace / "pixi")
shutil.copyfile(
test_data / "recipes/smokey/recipe.yaml", tmp_pixi_workspace / "pixi/recipe.yaml"
Expand All @@ -74,8 +59,8 @@ def test_build_using_rattler_build_backend(pixi: Path, tmp_pixi_workspace: Path)
assert package_to_be_built.exists()


def test_smokey(pixi: Path, tmp_pixi_workspace: Path) -> None:
test_data = get_data_dir("rattler-build-backend")
def test_smokey(pixi: Path, build_data: Path, tmp_pixi_workspace: Path) -> None:
test_data = build_data.joinpath("rattler-build-backend")
# copy the whole smokey project to the tmp_pixi_workspace
shutil.copytree(test_data, tmp_pixi_workspace / "test_data")
manifest_path = tmp_pixi_workspace / "test_data" / "smokey" / "pixi.toml"
Expand Down

0 comments on commit 35b7f7d

Please sign in to comment.