Files
rendercv/tests/test_hatch_scripts.py
2025-02-04 22:27:42 -05:00

52 lines
1.4 KiB
Python

import contextlib
import os
import pathlib
import subprocess
import tempfile
import pytest
@pytest.mark.parametrize(
"script_name",
[
"format",
"lint",
"check-types",
"precommit",
"update-schema",
"update-examples",
"docs:build",
"docs:update-entry-figures",
],
)
def test_scripts(script_name):
# If hatch is not installed, just pass the test
with contextlib.suppress(FileNotFoundError):
subprocess.run(["hatch", "run", script_name], check=True)
def test_executable():
# If hatch is not installed, just pass the test
with contextlib.suppress(FileNotFoundError):
root = pathlib.Path(__file__).parent.parent
bin_folder = root / "bin"
# remove the bin folder if it exists
if bin_folder.exists():
for file in bin_folder.iterdir():
file.unlink()
bin_folder.rmdir()
subprocess.run(["hatch", "run", "exe:create"], check=True)
executable_path = next(bin_folder.iterdir())
assert executable_path.is_file()
with tempfile.TemporaryDirectory() as temp_dir:
os.chdir(temp_dir)
subprocess.run([str(executable_path), "new", "John"], check=True)
subprocess.run([str(executable_path), "render", "John_CV.yaml"], check=True)
pdf_path = pathlib.Path(temp_dir) / "rendercv_output" / "John_CV.pdf"
assert pdf_path.exists()