pytest-html-plus 0.4.3__tar.gz → 0.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytest-html-plus
3
- Version: 0.4.3
4
- Summary: Get started with rich pytest reports in under 3 seconds. Just install the plugin — no setup required. The simplest, fastest reporter for pytest.
3
+ Version: 0.4.5
4
+ Summary: Generate Actionable, automatic screenshots, unified Pytest HTML report in less than 3 seconds — no hooks, merge plugins, no config, xdist-ready.
5
5
  License: MIT
6
6
  Keywords: pytest,pytest-html-plus,pytest-plugin,html-test-report,beautiful-test-report,shareable-test-results,test-report,test-results,unit-test-report,functional-test-report,test-summary,reporting,python-testing,automated-testing,test-runner,report-generator,continuous-integration,ci-cd,github-actions,jenkins,pytest-html,pytest-report
7
7
  Author: reporterplus
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
23
23
  ⚡ **Plug. Play. Debug without delay.**
24
24
  > _Get started with rich pytest reports in under 3 seconds. Just install — no setup required. The simplest, fastest reporter for pytest._
25
25
 
26
- ## Get a self-contained, actionable, easy-to-read single page HTML unified reports summarizing all your test results — no hassle, just clarity. Detect **flaky tests**, and optionally send reports via email**. Works beautifully with or without `xdist`.
26
+ ## Get a self-contained, actionable, easy-to-read single page HTML unified reports summarizing all your test results — no hassle, just clarity. Detect **flaky tests**, **attach screenshots** automatically without hooks and optionally send reports via email**. Works beautifully with or without `xdist`.
27
27
 
28
28
  ➡️ [View Demo Report](https://reporterplus.github.io/pytest-html-plus/)
29
29
 
@@ -155,3 +155,4 @@ See the [contribution guide](https://pytest-html-plus.readthedocs.io/en/latest/c
155
155
  ## 📜 License
156
156
 
157
157
  MIT
158
+
@@ -1,7 +1,7 @@
1
1
  ⚡ **Plug. Play. Debug without delay.**
2
2
  > _Get started with rich pytest reports in under 3 seconds. Just install — no setup required. The simplest, fastest reporter for pytest._
3
3
 
4
- ## Get a self-contained, actionable, easy-to-read single page HTML unified reports summarizing all your test results — no hassle, just clarity. Detect **flaky tests**, and optionally send reports via email**. Works beautifully with or without `xdist`.
4
+ ## Get a self-contained, actionable, easy-to-read single page HTML unified reports summarizing all your test results — no hassle, just clarity. Detect **flaky tests**, **attach screenshots** automatically without hooks and optionally send reports via email**. Works beautifully with or without `xdist`.
5
5
 
6
6
  ➡️ [View Demo Report](https://reporterplus.github.io/pytest-html-plus/)
7
7
 
@@ -132,4 +132,4 @@ See the [contribution guide](https://pytest-html-plus.readthedocs.io/en/latest/c
132
132
 
133
133
  ## 📜 License
134
134
 
135
- MIT
135
+ MIT
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "pytest-html-plus"
3
- version = "0.4.3"
4
- description = "Get started with rich pytest reports in under 3 seconds. Just install the plugin — no setup required. The simplest, fastest reporter for pytest."
3
+ version = "0.4.5"
4
+ description = "Generate Actionable, automatic screenshots, unified Pytest HTML report in less than 3 seconds — no hooks, merge plugins, no config, xdist-ready."
5
5
  readme = "README.md"
6
6
  authors = ["reporterplus"]
7
7
  license = "MIT"
@@ -1,14 +1,15 @@
1
1
  import json
2
2
  from datetime import datetime
3
3
 
4
- from pytest_html_plus.utils import is_main_worker, get_env_marker, get_git_information, get_report_title, \
4
+ from pytest_html_plus.utils import is_main_worker, get_env_marker, get_report_title, \
5
5
  get_python_version
6
6
 
7
7
 
8
- def write_plus_metadata_if_main_worker(config, report_path, output_path="plus_metadata.json"):
8
+ def write_plus_metadata_if_main_worker(config, report_path, output_path="plus_metadata.json", **kwargs):
9
9
  if not is_main_worker():
10
10
  return
11
- branch, commit = get_git_information()
11
+ branch = kwargs.get("git_branch", "NA")
12
+ commit = kwargs.get("git_commit", "NA")
12
13
  metadata = {
13
14
  "report_title": get_report_title(output_path=report_path),
14
15
  "environment": get_env_marker(config),
@@ -3,7 +3,7 @@ import base64
3
3
  import json
4
4
  import os
5
5
  import shutil
6
- from datetime import datetime
6
+ from datetime import datetime, timezone
7
7
  import html
8
8
  from sys import path
9
9
 
@@ -90,7 +90,7 @@ class JSONReporter:
90
90
  "line": lineno,
91
91
  "stdout": stdout,
92
92
  "stderr": stderr,
93
- "timestamp": datetime.utcnow().isoformat() + "Z",
93
+ "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
94
94
  "screenshot": screenshot,
95
95
  "logs": logs or [],
96
96
  "worker": worker,
@@ -162,11 +162,14 @@ def pytest_sessionfinish(session, exitstatus):
162
162
 
163
163
  def pytest_sessionstart(session):
164
164
  html_output = session.config.getoption("--html-output") or "report_output"
165
+ git_branch = session.config.getoption("--git-branch") or "NA"
166
+ git_commit = session.config.getoption("--git-commit") or "NA"
165
167
  configure_logging()
166
168
  session.config.addinivalue_line(
167
169
  "markers", "link(url): Add a link to external test case or documentation."
168
170
  )
169
- write_plus_metadata_if_main_worker(session.config, report_path=html_output)
171
+ write_plus_metadata_if_main_worker(session.config, report_path=html_output,
172
+ git_branch=git_branch, git_commit=git_commit)
170
173
 
171
174
 
172
175
  def pytest_load_initial_conftests(args):
@@ -221,6 +224,18 @@ def pytest_addoption(parser):
221
224
  default=None,
222
225
  help="Path to output the XML report (used with --generatexml)"
223
226
  )
227
+ parser.addoption(
228
+ "--git-branch",
229
+ action="store",
230
+ default="NA",
231
+ help="Helps show branch information on the report"
232
+ )
233
+ parser.addoption(
234
+ "--git-commit",
235
+ action="store",
236
+ default="NA",
237
+ help="Helps show commitId information on the report"
238
+ )
224
239
 
225
240
  import logging
226
241
  import sys
@@ -3,12 +3,6 @@ import subprocess
3
3
  import shutil
4
4
  import os
5
5
 
6
- from pytest_html_plus.compute_git_branch import get_repo_info
7
-
8
-
9
- def get_git_information():
10
- return get_repo_info()
11
-
12
6
  def get_env_marker(config):
13
7
  for arg in ("--env", "--environment"):
14
8
  if config.getoption(arg.lstrip("-").replace("-", "_"), default=None):
@@ -1,99 +0,0 @@
1
- import os
2
- import threading
3
- import subprocess
4
- from typing import Tuple, Optional
5
-
6
- _CACHE_LOCK = threading.Lock()
7
- _CACHED_REPO_INFO: Optional[Tuple[str, str]] = None
8
-
9
- # Env vars we treat as authoritative when present (CI) — cheap checks
10
- _CI_BRANCH_VARS = [
11
- "GITHUB_HEAD_REF", "GITHUB_REF_NAME",
12
- "CI_COMMIT_REF_NAME", "BITBUCKET_BRANCH",
13
- "BUILD_SOURCEBRANCHNAME", "CIRCLE_BRANCH",
14
- "BRANCH_NAME", "TRAVIS_BRANCH", "GIT_BRANCH"
15
- ]
16
- _CI_COMMIT_VARS = [
17
- "GITHUB_SHA", "CI_COMMIT_SHA", "BITBUCKET_COMMIT",
18
- "BUILD_SOURCEVERSION", "CIRCLE_SHA1", "TRAVIS_COMMIT"
19
- ]
20
-
21
- def _run_git(cmd: list, timeout: float = 1.0) -> Optional[str]:
22
- try:
23
- out = subprocess.check_output(cmd, stderr=subprocess.DEVNULL, timeout=timeout)
24
- return out.decode().strip()
25
- except Exception:
26
- return None
27
-
28
- def get_repo_info() -> Tuple[str, str]:
29
- """
30
- Return (branch, commit_sha).
31
- - Branch is a readable branch name or "NA".
32
- - Commit is full SHA or "NA".
33
- Behavior:
34
- 1) If REPORTER_BRANCH / REPORTER_COMMIT provided -> use them (manual override).
35
- 2) Else read common CI env vars (cheap).
36
- 3) Else call git once to get commit, and try to get branch (symbolic-ref / points-at).
37
- Result is cached per-process.
38
- """
39
- global _CACHED_REPO_INFO
40
-
41
- # 0) Manual overrides (explicit, highest priority) - zero cost
42
- manual_branch = os.getenv("REPORTER_BRANCH")
43
- manual_commit = os.getenv("REPORTER_COMMIT")
44
- if manual_branch or manual_commit:
45
- branch = manual_branch or "NA"
46
- commit = manual_commit or _run_git(["git", "rev-parse", "HEAD"]) or "NA"
47
- with _CACHE_LOCK:
48
- _CACHED_REPO_INFO = (branch, commit)
49
- return _CACHED_REPO_INFO
50
-
51
- # 1) CI envs (cheap, no subprocess)
52
- for var in _CI_COMMIT_VARS:
53
- val = os.getenv(var)
54
- if val:
55
- commit = val
56
- # try branch envs (if any)
57
- branch = next((os.getenv(bv) for bv in _CI_BRANCH_VARS if os.getenv(bv)), "NA")
58
- with _CACHE_LOCK:
59
- _CACHED_REPO_INFO = (branch, commit)
60
- return _CACHED_REPO_INFO
61
-
62
- for var in _CI_BRANCH_VARS:
63
- val = os.getenv(var)
64
- if val:
65
- # branch available but commit not set in CI envs -> get commit cheaply
66
- commit = _run_git(["git", "rev-parse", "HEAD"]) or "NA"
67
- with _CACHE_LOCK:
68
- _CACHED_REPO_INFO = (val, commit)
69
- return _CACHED_REPO_INFO
70
-
71
- # 2) Return cached if already computed
72
- with _CACHE_LOCK:
73
- if _CACHED_REPO_INFO is not None:
74
- return _CACHED_REPO_INFO
75
-
76
- # 3) Final: use git (one or two quick calls), cached afterwards
77
- commit = _run_git(["git", "rev-parse", "HEAD"]) or "NA"
78
- branch = _run_git(["git", "symbolic-ref", "--short", "-q", "HEAD"])
79
-
80
- # If symbolic-ref didn't return and commit is present, try local branches pointing to HEAD
81
- if not branch and commit != "NA":
82
- branches = _run_git(["git", "branch", "--points-at", "HEAD", "--format=%(refname:short)"])
83
- if branches:
84
- branch = branches.splitlines()[0].strip()
85
-
86
- if not branch:
87
- branch = "NA"
88
-
89
- with _CACHE_LOCK:
90
- _CACHED_REPO_INFO = (branch, commit)
91
- return _CACHED_REPO_INFO
92
-
93
- def display_repo_ref(short_len: int = 7) -> str:
94
- """Return a friendly display like 'feature/foo (5bb4c87)' or '5bb4c87'."""
95
- branch, commit = get_repo_info()
96
- commit_short = commit[:short_len] if commit and commit != "NA" else "NA"
97
- if branch and branch != "NA":
98
- return f"{branch} ({commit_short})"
99
- return commit_short