@@ -170,6 +170,10 @@ def __init__(self, test_result, test_method, outcome=SUCCESS, err=None, subTest=
170
170
self .lineno = lineno
171
171
self .doc = doc
172
172
173
+ # 'test_method' actually represents the test class that will lead to a
174
+ # 'testsuite' XML node
175
+ self .suite_doc = test_method .__doc__
176
+
173
177
def id (self ):
174
178
return self .test_id
175
179
@@ -465,8 +469,11 @@ def _get_info_by_testcase(self):
465
469
test_info = test_info [0 ]
466
470
testcase_name = test_info .test_name
467
471
if testcase_name not in tests_by_testcase :
468
- tests_by_testcase [testcase_name ] = []
469
- tests_by_testcase [testcase_name ].append (test_info )
472
+ tests_by_testcase [testcase_name ] = {
473
+ 'suite_doc' : test_info .suite_doc ,
474
+ 'tests' : []
475
+ }
476
+ tests_by_testcase [testcase_name ]['tests' ].append (test_info )
470
477
471
478
return tests_by_testcase
472
479
@@ -482,7 +489,7 @@ def _report_testsuite_properties(xml_testsuite, xml_document, properties):
482
489
483
490
_report_testsuite_properties = staticmethod (_report_testsuite_properties )
484
491
485
- def _report_testsuite (suite_name , tests , xml_document , parentElement ,
492
+ def _report_testsuite (suite_name , suite_doc , tests , xml_document , parentElement ,
486
493
properties ):
487
494
"""
488
495
Appends the testsuite section to the XML document.
@@ -512,6 +519,12 @@ def _report_testsuite(suite_name, tests, xml_document, parentElement,
512
519
skips = filter (lambda e : e .outcome == _TestInfo .SKIP , tests )
513
520
testsuite .setAttribute ('skipped' , str (len (list (skips ))))
514
521
522
+ if suite_doc :
523
+ comment = str (suite_doc )
524
+ # The use of '--' is forbidden in XML comments
525
+ comment = comment .replace ('--' , '--' )
526
+ testsuite .appendChild (xml_document .createComment (safe_unicode (comment )))
527
+
515
528
_XMLTestResult ._report_testsuite_properties (
516
529
testsuite , xml_document , properties )
517
530
@@ -633,7 +646,10 @@ def generate_reports(self, test_runner):
633
646
doc .appendChild (testsuite )
634
647
parentElement = testsuite
635
648
636
- for suite , tests in all_results .items ():
649
+ for suite , suite_info in all_results .items ():
650
+ suite_doc = suite_info ['suite_doc' ]
651
+ tests = suite_info ['tests' ]
652
+
637
653
if outputHandledAsString :
638
654
doc = Document ()
639
655
parentElement = doc
@@ -645,7 +661,7 @@ def generate_reports(self, test_runner):
645
661
646
662
# Build the XML file
647
663
testsuite = _XMLTestResult ._report_testsuite (
648
- suite_name , tests , doc , parentElement , self .properties
664
+ suite_name , suite_doc , tests , doc , parentElement , self .properties
649
665
)
650
666
651
667
if outputHandledAsString :
0 commit comments