36 lines
742 B
Python
36 lines
742 B
Python
from __future__ import annotations
|
|||
|
|
|
||
|
|
import uuid
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from tmux_shot import TmuxApp
|
||
|
|
|
||
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||
|
|
DEMO_TUI = REPO_ROOT / "examples" / "demo_tui.py"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def session_name() -> str:
|
||
|
|
return f"tmux_shot_test_{uuid.uuid4().hex[:8]}"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def demo_app(session_name: str, tmp_path: Path):
|
||
|
|
app = TmuxApp(session_name, command=f"python3 {DEMO_TUI}", width=80, height=24)
|
||
|
|
try:
|
||
|
|
yield app
|
||
|
|
finally:
|
||
|
|
try:
|
||
|
|
app.kill()
|
||
|
|
except Exception:
|
||
|
|
pass # already dead (e.g. the test quit it itself)
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def out_dir(tmp_path: Path) -> Path:
|
||
|
|
d = tmp_path / "out"
|
||
|
|
d.mkdir()
|
||
|
|
return d
|