Skip to content

Commit 0748afa

Browse files
Merge pull request #187 from prashanth-sams/184
#184
2 parents a5a28f4 + eaea813 commit 0748afa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pytest_html_reporter/plugin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ def pytest_terminal_summary(self, terminalreporter, exitstatus, config):
242242
global _execution_time
243243
_execution_time = time.time() - terminalreporter._sessionstarttime
244244

245+
if _execution_time < 60:
246+
_execution_time = str(round(_execution_time, 2)) + " secs"
247+
else:
248+
_execution_time = str(time.strftime("%H:%M:%S", time.gmtime(round(_execution_time)))) + " Hrs"
249+
245250
global _total
246251
_total = _pass + _fail + _xpass + _xfail + _skip + _error
247252

@@ -663,7 +668,7 @@ def _test_error(self, value):
663668
def renew_template_text(self, logo_url):
664669
template_text = html_template()
665670
template_text = template_text.replace("__custom_logo__", logo_url)
666-
template_text = template_text.replace("__execution_time__", str(round(_execution_time, 2)))
671+
template_text = template_text.replace("__execution_time__", str(_execution_time))
667672
# template_text = template_text.replace("__executed_by__", str(platform.uname()[1]))
668673
# template_text = template_text.replace("__os_name__", str(platform.uname()[0]))
669674
# template_text = template_text.replace("__python_version__", str(sys.version.split(' ')[0]))

pytest_html_reporter/template.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,10 @@ def html_template():
514514
<div class="col-md-6 card" style="max-width: 49%;">
515515
<div style="width:100%;height:500px;text-align: center;">
516516
<div class="card__content">
517-
<div style="margin-bottom: -4%; margin-left: 40%;">
517+
<div style="margin-bottom: -4%; margin-left: 30%;">
518518
<span style="color: darkgray; font-size: 17px;">
519519
<svg width="22px" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" style="margin: -1% 2% 0% 29%; -ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);" preserveAspectRatio="xMidYMid meet" viewBox="0 0 1536 1536"><path d="M896 416v448q0 14-9 23t-23 9H544q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h224V416q0-14 9-23t23-9h64q14 0 23 9t9 23zm416 352q0-148-73-273t-198-198t-273-73t-273 73t-198 198t-73 273t73 273t198 198t273 73t273-73t198-198t73-273zm224 0q0 209-103 385.5T1153.5 1433T768 1536t-385.5-103T103 1153.5T0 768t103-385.5T382.5 103T768 0t385.5 103T1433 382.5T1536 768z" fill="#a9a9a9"/></svg>
520-
Time taken __execution_time__ secs
520+
Time taken __execution_time__
521521
</span>
522522
</div>
523523
<div>
@@ -538,7 +538,7 @@ def html_template():
538538
</div>
539539
<div>
540540
<div style="margin-left: 50%;margin-top: -43%; max-height: 43%;">
541-
<canvas id="myChart" style="margin-top: 16%; height: 41%; margin-left: 16%; max-width: 75%;"></canvas>
541+
<canvas id="myChart" style="margin-top: 16%; height: 38%; margin-left: 16%; max-width: 75%;"></canvas>
542542
</div>
543543
</div>
544544
<div style="margin-top: 23%;position: static;">

0 commit comments

Comments
 (0)