pytest-html-plus 0.4.8__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,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytest-html-plus
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pytest-html-plus"
3
- version = "0.4.8"
3
+ version = "0.4.9"
4
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"]
@@ -12,12 +12,11 @@ def write_plus_metadata_if_main_worker(config, report_path, output_path="plus_me
12
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: #f2f4f7; }}
188
- .test {{ border: 1px solid #ddd; margin-bottom: 0.5rem; border-radius: 5px; background: #ffffff; }}
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; }}
@@ -179,12 +179,13 @@ def pytest_sessionstart(session):
179
179
  html_output = session.config.getoption("--html-output") or "report_output"
180
180
  git_branch = session.config.getoption("--git-branch") or "Pass --git-branch to populate git metadata"
181
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):
@@ -252,16 +253,10 @@ def pytest_addoption(parser):
252
253
  help="Helps show commitId information on the report"
253
254
  )
254
255
  parser.addoption(
255
- "--env",
256
+ "--rp-env",
256
257
  action="store",
257
- default="Pass --env or --environment <name> to populate environment",
258
- help="Helps show commitId information on the report"
259
- )
260
- parser.addoption(
261
- "--environment",
262
- action="store",
263
- default="Pass --env or --environment <name> to populate environment",
264
- help="Helps show commitId information on the report"
258
+ default="Pass --env or --environment or --rp-env <name> to populate environment",
259
+ help="Helps show env information on the report"
265
260
  )
266
261
 
267
262
  import logging
@@ -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 "Pass --env <name> to populate environment"
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