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
This commit is contained in:
parent
ff0e6cccfb
commit
e50fc9444a
5 changed files with 201 additions and 112 deletions
27
test/conftest.py
Normal file
27
test/conftest.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue