From 8136856ef5da9c61d9cd070813269ed00baa59e2 Mon Sep 17 00:00:00 2001 From: James Baber <67345633+james-baber@users.noreply.github.com> Date: Thu, 7 Oct 2021 20:26:37 -0500 Subject: [PATCH 1/4] Reverted getDescription updated so that getDescription now looks at the doc string first, otherwise it uses the test name --- HtmlTestRunner/result.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/HtmlTestRunner/result.py b/HtmlTestRunner/result.py index 96fb431..cab7235 100644 --- a/HtmlTestRunner/result.py +++ b/HtmlTestRunner/result.py @@ -164,8 +164,12 @@ def callback(): self.callback = callback def getDescription(self, test): - """ Return the test description if not have test name. """ - return str(test) + """ Return the test description if it has one, otherwise return the test name. """ + doc_first_line = test.shortDescription() + if self.descriptions and doc_first_line: + return doc_first_line + else: + return str(test) def startTest(self, test): """ Called before execute each method. """ From 8c7a2b414756ce0e08627870ad2806372f6f109f Mon Sep 17 00:00:00 2001 From: James Baber <67345633+james-baber@users.noreply.github.com> Date: Thu, 7 Oct 2021 20:30:13 -0500 Subject: [PATCH 2/4] Default template uses description Use the description as in the default template --- HtmlTestRunner/template/report_template.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HtmlTestRunner/template/report_template.html b/HtmlTestRunner/template/report_template.html index 4c2256b..94ff315 100644 --- a/HtmlTestRunner/template/report_template.html +++ b/HtmlTestRunner/template/report_template.html @@ -32,7 +32,7 @@

{{ title }}

{%- for test_case in tests_results %} {%- if not test_case.subtests is defined %} - {{ test_case.test_id.split(".")[-1] }} + {{ test_case.test_description }} {%- if test_case.outcome == test_case.SUCCESS -%} @@ -71,7 +71,7 @@

{{ title }}

{%- endif %} {%- else %} - {{ test_case.test_id.split(".")[-1] }} + {{ test_case.test_description }} {%- if test_case.outcome == test_case.SUCCESS -%} @@ -95,7 +95,7 @@

{{ title }}

{%- for subtest in test_case.subtests %} - {{ subtest.test_id.split(".")[-1] }} + {{ subtest.test_description }} {%- if subtest.outcome == subtest.SUCCESS -%} @@ -159,4 +159,4 @@

{{ title }}

}); - Date: Thu, 7 Oct 2021 20:57:51 -0500 Subject: [PATCH 3/4] Update report_template.html Added description as the default --- HtmlTestRunner/template/report_template.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HtmlTestRunner/template/report_template.html b/HtmlTestRunner/template/report_template.html index 94ff315..0ef4276 100644 --- a/HtmlTestRunner/template/report_template.html +++ b/HtmlTestRunner/template/report_template.html @@ -32,7 +32,7 @@

{{ title }}

{%- for test_case in tests_results %} {%- if not test_case.subtests is defined %} - {{ test_case.test_description }} + {{ test_case.test_description or test_case.test_id.split(".")[-1]}} {%- if test_case.outcome == test_case.SUCCESS -%} @@ -71,7 +71,7 @@

{{ title }}

{%- endif %} {%- else %} - {{ test_case.test_description }} + {{ test_case.test_description or test_case.test_id.split(".")[-1] }} {%- if test_case.outcome == test_case.SUCCESS -%} @@ -95,7 +95,7 @@

{{ title }}

{%- for subtest in test_case.subtests %} - {{ subtest.test_description }} + {{ subtest.test_description or test_case.test_id.split(".")[-1] }} {%- if subtest.outcome == subtest.SUCCESS -%} From 19cd53da7351383096866ecb7a85ec569c1609cf Mon Sep 17 00:00:00 2001 From: James Baber <67345633+james-baber@users.noreply.github.com> Date: Thu, 7 Oct 2021 20:59:36 -0500 Subject: [PATCH 4/4] Check description return to blank If there is no short description from the case then return a blank string --- HtmlTestRunner/result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HtmlTestRunner/result.py b/HtmlTestRunner/result.py index cab7235..b848e91 100644 --- a/HtmlTestRunner/result.py +++ b/HtmlTestRunner/result.py @@ -169,7 +169,7 @@ def getDescription(self, test): if self.descriptions and doc_first_line: return doc_first_line else: - return str(test) + return '' def startTest(self, test): """ Called before execute each method. """