topen/test/conftest.py
Marty Oehme 13c34b08e2
Some checks are pending
website / deploy (push) Blocked by required conditions
website / build (push) Waiting to run
test: Restructure test files
Extract the individual parsing tests (cli, env, rc) and add additional
configuration test file (TConf and config builder).

To extract the fixtures they have to go into an additional 'conftest.py'
file for pytest to recognize and automatically import them, see:
https://docs.pytest.org/en/stable/reference/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files

and:
https://docs.pytest.org/en/stable/how-to/fixtures.html#using-fixtures-from-other-projects
2025-11-29 12:29:35 +01:00

27 lines
638 B
Python

from pathlib import Path
import pytest
from topen import OPTIONS
@pytest.fixture
def fake_id(monkeypatch):
monkeypatch.setattr("sys.argv", ["topen", "0"])
@pytest.fixture
def isolate_env(monkeypatch):
# delete all existing env vars that could interfere
monkeypatch.delenv("EDITOR", raising=False)
monkeypatch.delenv("VISUAL", raising=False)
for opt in OPTIONS.values():
if opt.env:
monkeypatch.delenv(opt.env, raising=False)
@pytest.fixture
def fake_rc(tmp_path: Path, monkeypatch):
rc = tmp_path / "test.taskrc"
monkeypatch.setattr(OPTIONS["task_rc"], "default", rc)
return rc