add clan_core path helper function

This commit is contained in:
Jörg Thalheim
2023-09-15 16:34:16 +02:00
parent a65413c98e
commit d41cca2e28
2 changed files with 13 additions and 5 deletions

View File

@@ -4,12 +4,13 @@ import pytest
TEST_ROOT = Path(__file__).parent.resolve() TEST_ROOT = Path(__file__).parent.resolve()
PROJECT_ROOT = TEST_ROOT.parent PROJECT_ROOT = TEST_ROOT.parent
CLAN_CORE = PROJECT_ROOT.parent.parent
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def project_root() -> Path: def project_root() -> Path:
""" """
Root directory of the tests Root directory the clan-cli
""" """
return PROJECT_ROOT return PROJECT_ROOT
@@ -20,3 +21,11 @@ def test_root() -> Path:
Root directory of the tests Root directory of the tests
""" """
return TEST_ROOT return TEST_ROOT
@pytest.fixture(scope="session")
def clan_core() -> Path:
"""
Directory of the clan-core flake
"""
return CLAN_CORE

View File

@@ -5,7 +5,7 @@ from pathlib import Path
from typing import Iterator from typing import Iterator
import pytest import pytest
from root import PROJECT_ROOT from root import CLAN_CORE
from clan_cli.dirs import nixpkgs_source from clan_cli.dirs import nixpkgs_source
@@ -46,9 +46,8 @@ def test_flake(monkeymodule: pytest.MonkeyPatch) -> Iterator[Path]:
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def test_flake_with_core(monkeymodule: pytest.MonkeyPatch) -> Iterator[Path]: def test_flake_with_core(monkeymodule: pytest.MonkeyPatch) -> Iterator[Path]:
clan_core_flake = PROJECT_ROOT.parent.parent if not (CLAN_CORE / "flake.nix").exists():
if not (clan_core_flake / "flake.nix").exists():
raise Exception( raise Exception(
"clan-core flake not found. This test requires the clan-core flake to be present" "clan-core flake not found. This test requires the clan-core flake to be present"
) )
yield from create_flake(monkeymodule, "test_flake_with_core", clan_core_flake) yield from create_flake(monkeymodule, "test_flake_with_core", CLAN_CORE)