import subprocess

from fastapi import Request

from pygitweb.api.project import Project


def ActionPytestHtml(Action):
	"""
	ActionPytestHtml: Run pytest and render the results.
	"""

	def action_name(self) -> str:
		return "pytesthtml_run"

	def action(self, project: Project, req: Request = None) -> None:
		subprocess.run(["pytest", "--html=.pygitweb/pytest_report.html", "--self-contained-html"], cwd=project.path)