diff --git a/HtmlTestRunner/result.py b/HtmlTestRunner/result.py index 96fb431..b848e91 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 '' def startTest(self, test): """ Called before execute each method. """ diff --git a/HtmlTestRunner/template/report_template.html b/HtmlTestRunner/template/report_template.html index 4c2256b..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_id.split(".")[-1] }} + {{ 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_id.split(".")[-1] }} + {{ 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_id.split(".")[-1] }} + {{ subtest.test_description or test_case.test_id.split(".")[-1] }} {%- if subtest.outcome == subtest.SUCCESS -%} @@ -159,4 +159,4 @@

{{ title }}

}); -