pytest-html-plus 0.4.7__tar.gz → 0.4.9__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.7
4
- Summary: Generate Actionable, automatic screenshots, unified Pytest HTML report in less than 3 seconds — no hooks, merge plugins, no config, xdist-ready.
3
+ Version: 0.4.9
4
+ Summary: Generate Actionable, automatic screenshots, unified Mobile friendly 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
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "pytest-html-plus"
3
- version = "0.4.7"
4
- description = "Generate Actionable, automatic screenshots, unified Pytest HTML report in less than 3 seconds — no hooks, merge plugins, no config, xdist-ready."
3
+ version = "0.4.9"
4
+ description = "Generate Actionable, automatic screenshots, unified Mobile friendly 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"
@@ -8,16 +8,15 @@ from pytest_html_plus.utils import is_main_worker, get_env_marker, get_report_ti
8
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 = kwargs.get("git_branch", "NA")
12
- commit = kwargs.get("git_commit", "NA")
11
+ branch = kwargs.get("git_branch", "Pass --git-branch to populate git metadata")
12
+ commit = kwargs.get("git_commit", "Pass --git-commit to populate git metadata")
13
13
  metadata = {
14
14
  "report_title": get_report_title(output_path=report_path),
15
- "environment": get_env_marker(config),
15
+ "environment": kwargs.get("rp_env") or get_env_marker(config),
16
16
  "branch": branch,
17
17
  "commit": commit,
18
18
  "python_version": get_python_version(),
19
19
  "generated_at": datetime.now().isoformat()
20
20
  }
21
21
  with open(output_path, "w") as f:
22
- print(metadata)
23
22
  json.dump(metadata, f, indent=2)
@@ -60,6 +60,7 @@ class JSONReporter:
60
60
  else:
61
61
  self.metadata = {}
62
62
 
63
+
63
64
  def log_result(
64
65
  self,
65
66
  test_name,
@@ -148,6 +149,22 @@ class JSONReporter:
148
149
  return os.path.join("screenshots", file)
149
150
  return None
150
151
 
152
+ def copy_json_report(self):
153
+ """
154
+ Copies the source JSON report into the report output directory.
155
+ """
156
+ if not os.path.exists(self.report_path):
157
+ return
158
+
159
+ os.makedirs(self.output_dir, exist_ok=True)
160
+
161
+ dest_path = os.path.join(
162
+ self.output_dir,
163
+ os.path.basename(self.report_path)
164
+ )
165
+
166
+ shutil.copyfile(self.report_path, dest_path)
167
+
151
168
  def generate_copy_button(self, content, label):
152
169
  if isinstance(content, list):
153
170
  # Convert list to string (for logs)
@@ -169,6 +186,7 @@ class JSONReporter:
169
186
 
170
187
  def generate_html_report(self):
171
188
  # Extract all unique markers
189
+ self.copy_json_report()
172
190
  ignore_markers = {"link"}
173
191
  all_markers = set()
174
192
  for test in self.results:
@@ -184,16 +202,35 @@ class JSONReporter:
184
202
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
185
203
  <style>
186
204
 
187
- body {{ font-family: Arial, sans-serif; padding: 1rem; background: #f9f9f9; }}
188
- .test {{ border: 1px solid #ddd; margin-bottom: 0.5rem; border-radius: 5px; background: white; }}
205
+ body {{
206
+ font-family: Arial, sans-serif;
207
+ padding: 1rem;
208
+ background: #FAF7F2;
209
+ }}
210
+ .test {{
211
+ border: 1px solid #D9C3A5;
212
+ margin-bottom: 0.5rem;
213
+ border-radius: 5px;
214
+ background: #FDFBF7;
215
+ }}
189
216
  .header {{ padding: 0.5rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }}
190
- .header.passed {{ background: #e6f4ea; color: #2f7a33; }}
191
- .header.failed {{ background: #fdecea; color: #a83232; }}
192
- .header.skipped {{ background: #fff8e1; color: #b36b00; }}
217
+ .header.passed {{
218
+ background: #E1F3E8;
219
+ color: #1E6B3A;
220
+ border-left: 4px solid #2E7D32;
221
+ }}
222
+ .header.failed {{
223
+ background: #FBE4E4;
224
+ color: #8B1E1E;
225
+ border-left: 4px solid #C62828;
226
+ }}
227
+ .header.skipped {{
228
+ background: #fff8e1;
229
+ color: #b36b00;
230
+ }}
193
231
  .header.error {{
194
- background: #fdecea; /* light red / pink */
195
- color: #b71c1c; /* deep red */
196
- border-left: 4px solid #d32f2f;
232
+ background: #fdecea;
233
+ color: #b71c1c;
197
234
  }}
198
235
  .details {{ padding: 0.5rem 1rem; display: none; border-top: 1px solid #ddd; }}
199
236
  .toggle::before {{ content: "▶"; display: inline-block; margin-right: 0.5rem; transition: transform 0.3s ease; }}
@@ -293,6 +330,13 @@ class JSONReporter:
293
330
  width: 100%;
294
331
  border-collapse: collapse;
295
332
  }}
333
+
334
+ .muted-hint code {{
335
+ background: #f1f5f9;
336
+ padding: 2px 4px;
337
+ border-radius: 4px;
338
+ font-size: 0.9em;
339
+ }}
296
340
 
297
341
  .report-metadata th, .report-metadata td {{
298
342
  text-align: left;
@@ -587,8 +631,8 @@ class JSONReporter:
587
631
  </script>
588
632
  </head>
589
633
  <body>
590
- <div class="report-metadata">
591
- <h2 onclick="this.nextElementSibling.classList.toggle('hidden')" style="cursor: pointer; font-size: 12px;">
634
+ <div class="report-metadata" style="background: #f2f4f7;">
635
+ <h2 onclick="this.nextElementSibling.classList.toggle('hidden')" style="cursor: pointer; font-size: 12px; ">
592
636
  Execution Metadata (click to toggle)
593
637
  {self.generate_copy_button(self.metadata, "metadata")}
594
638
  </h2>
@@ -683,9 +727,21 @@ class JSONReporter:
683
727
 
684
728
  # Add checkboxes for all markers
685
729
  marker_counts = self.filters.get("marker_counts", {})
686
- for marker in sorted(marker_counts):
687
- count = marker_counts[marker]
688
- html += f'<label><input type="checkbox" value="{marker}" /> {marker} ({count})</label> '
730
+ if not marker_counts:
731
+ html += (
732
+ '<span class="muted-hint">'
733
+ 'Use <code>pytest.mark.*</code> to enable marker filters'
734
+ '</span>'
735
+ )
736
+ else:
737
+ for marker in sorted(marker_counts):
738
+ count = marker_counts[marker]
739
+ html += (
740
+ f'<label>'
741
+ f'<input type="checkbox" value="{marker}" /> '
742
+ f'{marker} ({count})'
743
+ f'</label> '
744
+ )
689
745
 
690
746
  html += '<div id="tests-container">'
691
747
 
@@ -177,14 +177,15 @@ def pytest_sessionfinish(session, exitstatus):
177
177
 
178
178
  def pytest_sessionstart(session):
179
179
  html_output = session.config.getoption("--html-output") or "report_output"
180
- git_branch = session.config.getoption("--git-branch") or "NA"
181
- git_commit = session.config.getoption("--git-commit") or "NA"
180
+ git_branch = session.config.getoption("--git-branch") or "Pass --git-branch to populate git metadata"
181
+ git_commit = session.config.getoption("--git-commit") or "Pass --git-commit to populate git metadata"
182
+ rp_env = session.config.getoption("--rp-env") or "Pass --env or --environment or --rp-env <name> to populate environment"
182
183
  configure_logging()
183
184
  session.config.addinivalue_line(
184
185
  "markers", "link(url): Add a link to external test case or documentation."
185
186
  )
186
187
  write_plus_metadata_if_main_worker(session.config, report_path=html_output,
187
- git_branch=git_branch, git_commit=git_commit)
188
+ git_branch=git_branch, git_commit=git_commit, rp_env=rp_env)
188
189
 
189
190
 
190
191
  def pytest_load_initial_conftests(args):
@@ -242,15 +243,21 @@ def pytest_addoption(parser):
242
243
  parser.addoption(
243
244
  "--git-branch",
244
245
  action="store",
245
- default="NA",
246
+ default="Pass --git-branch to populate git metadata",
246
247
  help="Helps show branch information on the report"
247
248
  )
248
249
  parser.addoption(
249
250
  "--git-commit",
250
251
  action="store",
251
- default="NA",
252
+ default="Pass --git-commit to populate git metadata",
252
253
  help="Helps show commitId information on the report"
253
254
  )
255
+ parser.addoption(
256
+ "--rp-env",
257
+ action="store",
258
+ default="Pass --env or --environment or --rp-env <name> to populate environment",
259
+ help="Helps show env information on the report"
260
+ )
254
261
 
255
262
  import logging
256
263
  import sys
@@ -7,7 +7,7 @@ def get_env_marker(config):
7
7
  for arg in ("--env", "--environment"):
8
8
  if config.getoption(arg.lstrip("-").replace("-", "_"), default=None):
9
9
  return config.getoption(arg.lstrip("-").replace("-", "_"))
10
- return "NA"
10
+ return "Pass --env or --rp-env or --environment <name> to populate environment"
11
11
 
12
12
  def get_report_title(output_path):
13
13
  report_path = output_path