Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
capturescreenshots: "all"
testpath: "tests/browser/test_playwright.py"
usepoetry: "true"
xmlreport: "report_output_playwright/report.xml"
xmlreport: "report.xml"
gitbranch: "$(git rev-parse --abbrev-ref HEAD)"

- name: Upload reports
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-version: [ "3.13" ]
python-version: [ "3.11" ]

steps:
- name: 📥 Checkout code
Expand Down Expand Up @@ -43,11 +43,11 @@ jobs:

- name: 🧪 Run tests with coverage
run: |
poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report report_output/final_xml_windows.xml --git-branch $(git rev-parse --abbrev-ref HEAD)
poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report final_xml_windows.xml --git-branch $(git rev-parse --abbrev-ref HEAD)

- name: 🧪 Run tests with warnings enabled
run: |
$env:PYTHONWARNINGS="error"; poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --html-output=report_output_warnings --xml-report report_output/final_xml_windows_with_warnings.xml --git-branch $(git rev-parse --abbrev-ref HEAD)
$env:PYTHONWARNINGS="error"; poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --html-output=report_output_warnings --xml-report final_xml_windows_with_warnings.xml --git-branch $(git rev-parse --abbrev-ref HEAD)

- name: Upload HTML Report
if: always()
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: ["3.10", "3.11", "3.12", "3.13" ]

steps:
- name: 📥 Checkout code
Expand All @@ -35,13 +35,13 @@ jobs:
run: |
export REPORT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
export REPORT_COMMIT="$(git rev-parse HEAD)"
poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report report_output/final_xml_ubuntu.xml --git-branch "$REPORT_BRANCH" --git-commit "$REPORT_COMMIT"
poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report final_xml_ubuntu.xml --git-branch "$REPORT_BRANCH" --git-commit "$REPORT_COMMIT"

- name: 🧪 Run tests with warnings enabled
run: |
export REPORT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
export REPORT_COMMIT="$(git rev-parse HEAD)"
PYTHONWARNINGS=error poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report report_output/final_xml_ubuntu_warnings.xml --html-output=report_output_warnings --git-branch "$REPORT_BRANCH" --git-commit "$REPORT_COMMIT"
PYTHONWARNINGS=error poetry run pytest --cov=pytest_html_plus tests/ --cov-fail-under=39 --cov-report=term --reruns 1 --ignore=tests/browser --generate-xml --xml-report final_xml_ubuntu_warnings.xml --html-output=report_output_warnings --git-branch "$REPORT_BRANCH" --git-commit "$REPORT_COMMIT"


- name: Upload HTML Report
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Overview
- **Default**
- **Use Case**
* - ``--json-report``
- Path to save individual JSON test reports
- Name of the JSON report file generated alongside the HTML report
- ``final_report.json``
- Use in CI to parse/export test metadata
* - ``--capture-screenshots``
Expand Down
14 changes: 9 additions & 5 deletions docs/cli/execution-metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ Flags Overview
**Accepted Values:** Any valid commit hash (e.g., ``5bb4c87e9da4ff1780540b25a04725ade5c3bc37``)
Helps ensure full traceability of test runs, especially in detached HEAD mode.

- ``--env`` or ``--environment`` or ``-rp-env``
Adds the value of a specific environment variable to the report metadata.
**Default:** ``None``
**Accepted Values:** A single environment variable key (e.g., ``BUILD_ID``) or any text of your choice for (e.g. your env name like staging)
Useful for adding CI job IDs, build numbers, or other contextual metadata.
- ``--env`` and ``--environment`` are **not owned or defined by pytest-html-plus**.
If these options are already provided by your test suite, plugins, or CI setup,
pytest-html-plus will capture and display their values in the report metadata
when they are available.

If your project does **not** define ``--env`` or ``--environment`` and you want
to explicitly add environment context (for example ``staging``, ``production``,
``BUILD_ID``, or a CI job identifier), use ``--rp-env``, which is **owned and fully
supported by pytest-html-plus**.

Usage Examples
--------------
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/json-report.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Overview
--------

- **Default Output**: `final_report.json`
- **Type**: File path
- **Type**: File Name
- **Usage Context**: CI pipelines, custom dashboards, post-processing

Example
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-html-plus"
version = "0.4.9"
version = "0.5.0"
description = "Generate Actionable, automatic screenshots, unified Mobile friendly Pytest HTML report in less than 3 seconds — no hooks, merge plugins, no config, xdist-ready."
readme = "README.md"
authors = ["reporterplus"]
Expand Down
6 changes: 5 additions & 1 deletion pytest_html_plus/compute_report_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from datetime import datetime

from pytest_html_plus.utils import is_main_worker, get_env_marker, get_report_title, \
Expand All @@ -8,6 +9,7 @@
def write_plus_metadata_if_main_worker(config, report_path, output_path="plus_metadata.json", **kwargs):
if not is_main_worker():
return
metadata_path = os.path.join(report_path, output_path)
branch = kwargs.get("git_branch", "Pass --git-branch to populate git metadata")
commit = kwargs.get("git_commit", "Pass --git-commit to populate git metadata")
metadata = {
Expand All @@ -18,5 +20,7 @@ def write_plus_metadata_if_main_worker(config, report_path, output_path="plus_me
"python_version": get_python_version(),
"generated_at": datetime.now().isoformat()
}
with open(output_path, "w") as f:
os.makedirs(report_path, exist_ok=True)

with open(metadata_path, "w") as f:
json.dump(metadata, f, indent=2)
16 changes: 0 additions & 16 deletions pytest_html_plus/generate_html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,6 @@ def find_screenshot_and_copy(self, test_name):
return os.path.join("screenshots", file)
return None

def copy_json_report(self):
"""
Copies the source JSON report into the report output directory.
"""
if not os.path.exists(self.report_path):
return

os.makedirs(self.output_dir, exist_ok=True)

dest_path = os.path.join(
self.output_dir,
os.path.basename(self.report_path)
)

shutil.copyfile(self.report_path, dest_path)

def generate_copy_button(self, content, label):
if isinstance(content, list):
Expand All @@ -186,7 +171,6 @@ def generate_copy_button(self, content, label):

def generate_html_report(self):
# Extract all unique markers
self.copy_json_report()
ignore_markers = {"link"}
all_markers = set()
for test in self.results:
Expand Down
Loading