1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pathlib import Path
from pygitweb.api.subpage import Subpage
from pygitweb.config import settings
class SubpagePytestHtml(Subpage):
"""
SubpagePytestHtml: Render the latest Pytest results for a project.
"""
def subpage_name(self) -> str:
return "pytesthtml"
def link_name(self, project: str) -> str | None:
return "Pytest Results"
def subpage_html(self, project: str) -> str | None:
report_path = Path(settings.PROJECTROOT) / project / ".pygitweb" / "pytest_report.html"
if not report_path.is_file():
return "<p>No pytest report found.</p>"
return report_path.read_text(encoding="utf-8")