1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
"""Utility functions for tmuxp fixtures."""
from __future__ import annotations
import pathlib
from tests.constants import FIXTURE_PATH
def get_workspace_file(
file: str | pathlib.Path,
) -> pathlib.Path:
"""Return fixture data, relative to __file__."""
if isinstance(file, str):
file = pathlib.Path(file)
return FIXTURE_PATH / file
def read_workspace_file(
file: pathlib.Path | str,
) -> str:
"""Return fixture data, relative to __file__."""
if isinstance(file, str):
file = pathlib.Path(file)
return get_workspace_file(file).open().read()
def write_config(
config_path: pathlib.Path,
filename: str,
content: str,
) -> pathlib.Path:
"""Write configuration content to file."""
config = config_path / filename
config.write_text(content, encoding="utf-8")
return config
|