Feature: pluggable HTML themes via Jinja2 template inheritance
評価
この issue はまだ評価されていません。
説明
Motivation
There is clear user demand for a modernised report UI (see #913, #904, #884). Currently, anyone who wants a different visual style has to override CSS after the fact or maintain a separate fork. pytest-html could instead offer first-class theme support, making it trivial to ship alternative report styles and for the community to contribute new ones.
Proposed design
1. Jinja2 template inheritance with {% extends %}
Factor the current index.jinja2 into a base template and per-theme overrides:
resources/
base.jinja2 # shared HTML skeleton with {% block %} placeholders
classic/
layout.jinja2 # {% extends "base.jinja2" %} — current look
style.css
modern/
layout.jinja2 # {% extends "base.jinja2" %} — card-based dashboard
style.css
Only 4 blocks actually differ between visual styles:
{% block header %}— page title / navbar{% block summary %}— run stats presentation (flat text vs stat cards with percentages){% block filters %}— checkboxes vs toggle switches{% block footer %}— generation info placement
Everything else is shared in base.jinja2: the results table, the <template> for result rows, the media viewer, the JS data container, and the script include.
2. Config option
# pytest.ini / pyproject.toml
[tool.pytest.ini_options]
html_theme = "modern" # default: "classic"
# plugin.py
parser.addini(
"html_theme",
type="string",
default="classic",
help="HTML report theme ('classic' or 'modern').",
)
3. Template loader change
Pass [theme_path, resources_path] to Jinja2's FileSystemLoader so each theme's layout.jinja2 can do {% extends "base.jinja2" %} and the loader resolves base.jinja2 from the parent resources directory. Minimal change to _read_template.
4. Extra template variables
A modern card-based theme benefits from a few additional pre-computed template variables. These are cheap to compute and can be passed unconditionally so all themes have them available:
start_time/end_time— formatted timestamps for the suiteduration_display— human-readable total durationtotal_count— total tests excluding reruns
This is ~15 lines in _generate_report().
Benefits
- Backward compatible —
classicis the default; no one's custom CSS breaks - Extensible — new themes are just a directory with
layout.jinja2+style.css - Low risk — the JS logic, data model, hooks, and Python backend are untouched
- Community-friendly — lowers the bar for contributing visual improvements
What this does NOT change
- No new features or hooks — purely a presentation-layer refactor
- No change to the default appearance (classic remains default)
- No JS modifications required
- 主要言語
- Python
- スター
- 779
- フォーク
- 259
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-html のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
pytest-dev/pytest-html#1077 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
pytest-dev/pytest-html#1039 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
pytest-dev/pytest-html#1027 ·
-
pytest-html does not escape HTML in testId (v4.2.0)対応中かも @golikovichev が 121 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
pytest-dev/pytest-html#1024 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
pytest-dev/pytest-html#1010 ·
pytest-dev/pytest-html の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Multi-day events show "Ended" while still in progress対応中かも @tarunagnihotri534 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
data-umbrella/du-event-board#231 · コメント 2 件 ·
-
avl_automation: the generated control surface block isn't valid XML (typo in avl_out_parse.py)対応中かも @brksol が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
PX4/PX4-gazebo-models#164 ·