Move the `tests` folder to `clan_cli/tests`. As we now want part of our tests to live next to the functions that are tested - tests that are not in the `/tests` module also need access to the configured test fixtures that are exposed by the `pytest_plugins` declaration. The following folder structure doesn't support this model: ``` ├── clan_cli │ ├── api │ │ └── api_init_test.py ├── tests/ │ ├── conftest.py │ └── ... ``` Here `api_init_test.py` even when importing the test functions will not have the fixtures configured. There is a way to configure python to import the fixtures from another [`project/module`](https://docs.pytest.org/en/stable/how-to/fixtures.html#using-fixtures-from-other-projects), but this seems to *generally* be discouraged. So moving the `conftest.py` to the toplevel and the `/tests` folder into the toplevel seems to be a sensible choice choice.
36 lines
665 B
Python
36 lines
665 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
TEST_ROOT = Path(__file__).parent.resolve()
|
|
PROJECT_ROOT = TEST_ROOT.parent
|
|
if CLAN_CORE_ := os.environ.get("CLAN_CORE_PATH"):
|
|
CLAN_CORE = Path(CLAN_CORE_)
|
|
else:
|
|
CLAN_CORE = PROJECT_ROOT.parent.parent.parent
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def project_root() -> Path:
|
|
"""
|
|
Root directory the clan-cli
|
|
"""
|
|
return PROJECT_ROOT
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def test_root() -> Path:
|
|
"""
|
|
Root directory of the tests
|
|
"""
|
|
return TEST_ROOT
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def clan_core() -> Path:
|
|
"""
|
|
Directory of the clan-core flake
|
|
"""
|
|
return CLAN_CORE
|