diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 34181ab..beeece8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,3 @@ # Library /pytest_html_reporter/ @prashanth-sams -/tests/ @prashanth-sams -/unittests/ @prashanth-sams \ No newline at end of file +/tests/ @prashanth-sams \ No newline at end of file diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8ce1a18..8ef1a5b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,32 @@ Change Log ========== +0.2.8 (11/02/2022) +------------------- +- Fixed all the code related inconsistencies + +0.2.7 (11/02/2022) +------------------- +- Added custom title on Dashboard + +0.2.6 (25/04/2021) +------------------- +- Dashboard Execution Time in H:M:S Hour:Minute:Second format +- Shortened long error text to open in a dialog box + +0.2.5 (20/04/2021) +------------------- +- Fixed incorrect execution time in the test metrics + +0.2.4 (19/04/2021) +------------------- +- Added support to download the current report (dashboard) in pdf format + +0.2.3 (28/09/2020) +------------------- +- Fixed UI bugs in dashboard and Archives layout +- Added error details on failed test cases + 0.2.2 (13/09/2020) ------------------- - Codecov diff --git a/README.rst b/README.rst index a7571a6..95a427d 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ Installation .. code-block:: console - $ pip install pytest-html-reporter + $ pip3 install pytest-html-reporter Usage diff --git a/pytest_html_reporter/plugin.py b/pytest_html_reporter/plugin.py index 5925080..6caf172 100644 --- a/pytest_html_reporter/plugin.py +++ b/pytest_html_reporter/plugin.py @@ -8,7 +8,6 @@ import json import glob from collections import Counter -import codecs from PIL import Image from io import BytesIO import shutil @@ -203,9 +202,12 @@ def __init__(self, path, config): self.rerun = 0 if has_rerun else None def pytest_runtest_teardown(self, item, nextitem): - global _test_name + global _test_name, _duration _test_name = item.name + _test_end_time = time.time() + _duration = _test_end_time - _start_execution_time + if (self.rerun is not None) and (max_rerun() is not None): self.previous_test_name(_test_name) self._test_names(_test_name) self.append_test_metrics_row() @@ -222,7 +224,7 @@ def previous_test_name(self, _test_name): def pytest_runtest_setup(item): global _start_execution_time - _start_execution_time = round(time.time()) + _start_execution_time = time.time() def pytest_sessionfinish(self, session): if _suite_name is not None: self.append_suite_metrics_row(_suite_name) @@ -259,6 +261,11 @@ def pytest_terminal_summary(self, terminalreporter, exitstatus, config): global _execution_time _execution_time = time.time() - terminalreporter._sessionstarttime + if _execution_time < 60: + _execution_time = str(round(_execution_time, 2)) + " secs" + else: + _execution_time = str(time.strftime("%H:%M:%S", time.gmtime(round(_execution_time)))) + " Hrs" + global _total _total = _pass + _fail + _xpass + _xfail + _skip + _error @@ -330,9 +337,8 @@ def pytest_runtest_makereport(self, item, call): for line in rep.longreprtext.splitlines(): exception = line.startswith("E ") if exception: - # self.update_test_error(line.replace("E ", "")) longerr += line + "\n" - self.update_test_error(longerr) + self.update_test_error(longerr.replace("E ", "")) else: self.increment_error() self.update_test_status("ERROR") @@ -347,19 +353,23 @@ def pytest_runtest_makereport(self, item, call): self.increment_xfail() self.update_test_status("xFAIL") if rep.longrepr: + longerr = "" for line in rep.longreprtext.splitlines(): exception = line.startswith("E ") if exception: - self.update_test_error(line.replace("E ", "")) + longerr += line + "\n" + self.update_test_error(longerr.replace("E ", "")) else: self.increment_skip() self.update_test_status("SKIP") if rep.longrepr: + longerr = "" for line in rep.longreprtext.splitlines(): - self.update_test_error(line) + longerr += line + "\n" + self.update_test_error(longerr) def append_test_metrics_row(self): - global _test_metrics_content, _pvalue + global _test_metrics_content, _pvalue, _duration test_row_text = """ @@ -367,9 +377,32 @@ def append_test_metrics_row(self): __name__ __stat__ __dur__ - __msg__ + + __msg__ + __floating_error_text__ + """ + + floating_error_text = """ + (...) + + """ + if (self.rerun is not None) and (max_rerun() is not None): if (_test_status == 'FAIL') or (_test_status == 'ERROR'): _pvalue += 1 @@ -381,7 +414,15 @@ def append_test_metrics_row(self): test_row_text = test_row_text.replace("__name__", str(_test_name)) test_row_text = test_row_text.replace("__stat__", str(_test_status)) test_row_text = test_row_text.replace("__dur__", str(round(_duration, 2))) - test_row_text = test_row_text.replace("__msg__", str(_current_error)) + test_row_text = test_row_text.replace("__msg__", str(_current_error[:50])) + floating_error_text = floating_error_text.replace("__runt__", str(time.time()).replace('.', '')) + + if len(_current_error) < 49: + test_row_text = test_row_text.replace("__floating_error_text__", str('')) + else: + test_row_text = test_row_text.replace("__floating_error_text__", str(floating_error_text)) + test_row_text = test_row_text.replace("__full_msg__", str(_current_error)) + _test_metrics_content += test_row_text _pvalue = 0 @@ -391,7 +432,14 @@ def append_test_metrics_row(self): test_row_text = test_row_text.replace("__name__", str(_test_name)) test_row_text = test_row_text.replace("__stat__", str(_test_status)) test_row_text = test_row_text.replace("__dur__", str(round(_duration, 2))) - test_row_text = test_row_text.replace("__msg__", str(_current_error)) + test_row_text = test_row_text.replace("__msg__", str(_current_error[:50])) + floating_error_text = floating_error_text.replace("__runt__", str(time.time()).replace('.', '')) + + if len(_current_error) < 49: + test_row_text = test_row_text.replace("__floating_error_text__", str('')) + else: + test_row_text = test_row_text.replace("__floating_error_text__", str(floating_error_text)) + test_row_text = test_row_text.replace("__full_msg__", str(_current_error)) _test_metrics_content += test_row_text @@ -403,7 +451,14 @@ def append_test_metrics_row(self): test_row_text = test_row_text.replace("__name__", str(_test_name)) test_row_text = test_row_text.replace("__stat__", str(_test_status)) test_row_text = test_row_text.replace("__dur__", str(round(_duration, 2))) - test_row_text = test_row_text.replace("__msg__", str(_current_error)) + test_row_text = test_row_text.replace("__msg__", str(_current_error[:50])) + floating_error_text = floating_error_text.replace("__runt__", str(time.time()).replace('.', '')) + + if len(_current_error) < 49: + test_row_text = test_row_text.replace("__floating_error_text__", str('')) + else: + test_row_text = test_row_text.replace("__floating_error_text__", str(floating_error_text)) + test_row_text = test_row_text.replace("__full_msg__", str(_current_error)) _test_metrics_content += test_row_text @@ -632,7 +687,7 @@ def _test_error(self, value): def renew_template_text(self, logo_url): template_text = html_template() template_text = template_text.replace("__custom_logo__", logo_url) - template_text = template_text.replace("__execution_time__", str(round(_execution_time, 2))) + template_text = template_text.replace("__execution_time__", str(_execution_time)) template_text = template_text.replace("__title__", _title) # template_text = template_text.replace("__executed_by__", str(platform.uname()[1])) # template_text = template_text.replace("__os_name__", str(platform.uname()[0])) diff --git a/pytest_html_reporter/template.py b/pytest_html_reporter/template.py index 65825ea..92282e6 100644 --- a/pytest_html_reporter/template.py +++ b/pytest_html_reporter/template.py @@ -7,22 +7,27 @@ def html_template(): Pytest HTML Reporter - - - - + + + + - + + + + + - + +