2023-03-13 13:00:12 +00:00
|
|
|
from contextlib import suppress
|
2021-01-04 21:26:04 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2023-03-13 07:57:57 +00:00
|
|
|
from potodo.potodo import main
|
2021-01-04 21:26:04 +00:00
|
|
|
|
2023-03-13 07:57:57 +00:00
|
|
|
|
|
|
|
@pytest.fixture(name="repo_dir")
|
|
|
|
def _repo_dir():
|
2021-01-04 21:26:04 +00:00
|
|
|
return Path(__file__).resolve().parent / "fixtures" / "repository"
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2023-03-13 07:57:57 +00:00
|
|
|
def run_potodo(repo_dir, capsys, monkeypatch):
|
|
|
|
def run_it(argv):
|
|
|
|
monkeypatch.setattr(
|
|
|
|
"sys.argv", ["potodo", "--no-cache", "-p", str(repo_dir)] + argv
|
2023-03-12 20:49:19 +00:00
|
|
|
)
|
2023-03-13 13:00:12 +00:00
|
|
|
with suppress(SystemExit):
|
2023-03-13 07:57:57 +00:00
|
|
|
main()
|
|
|
|
return capsys.readouterr()
|
2023-03-12 20:49:19 +00:00
|
|
|
|
2023-03-13 07:57:57 +00:00
|
|
|
return run_it
|