| |
@@ -41,7 +41,7 @@
|
| |
reporter = self.junit.node_reporter(report.nodeid)
|
| |
reporter.add_property(name, value)
|
| |
else:
|
| |
- pass #plugin is installed but not run with --junitxml
|
| |
+ pass # plugin is installed but not run with --junitxml
|
| |
|
| |
def _add_marks(self, item, report):
|
| |
""" add markers to the junit xml """
|
| |
@@ -61,11 +61,34 @@
|
| |
rep = outcome.get_result()
|
| |
title_regex = re.compile("^.[T|t]itle\s*:\s*.*")
|
| |
if item._obj.__doc__:
|
| |
- tc_name = item._obj.__doc__.strip().split('\n')[0]
|
| |
- for line in item._obj.__doc__.strip().split('\n'):
|
| |
+ doc_strings = item._obj.__doc__.strip()
|
| |
+ doc_list = re.sub('(\n\s*[:|@][A-Za-z0-9_-]*:)', '\n\\1',
|
| |
+ doc_strings, 0, re.DOTALL).split('\n')
|
| |
+ tc_name = doc_list[0]
|
| |
+ # Get index of test case title
|
| |
+ for line in doc_list:
|
| |
if title_regex.match(line):
|
| |
- tc_name = re.sub("^.[T|t]itle\s*:\s*", "", line)
|
| |
- break
|
| |
+ tc_start = doc_list.index(line)
|
| |
+ # get the end of title which is a space
|
| |
+ if len(doc_strings) > 1:
|
| |
+ try:
|
| |
+ # when having multiple paragraphs in docstrings
|
| |
+ # splitting with new line causes line breaks
|
| |
+ # represented with spaces.
|
| |
+ # so end of the Title string is till the
|
| |
+ # next space in the list.
|
| |
+ tc_end = doc_list.index('', (tc_start))
|
| |
+ except ValueError:
|
| |
+ # in the case where docstrings contain single line
|
| |
+ # or single paragraph with only @Title.
|
| |
+ # there will be no space so ValueError
|
| |
+ # exception is caught.in which case
|
| |
+ # length of title is till end of the docstrings.
|
| |
+ tc_end = len(doc_list)
|
| |
+ tc_title = ' '.join([tc.strip() for tc in doc_list[tc_start: tc_end]])
|
| |
+ else:
|
| |
+ tc_title = ''.join(doc_list[tc_start])
|
| |
+ tc_name = re.sub("^.[T|t]itle\s*:\s*", "", tc_title)
|
| |
rep.nodeid = '::'.join(rep.nodeid.split('::')[0:-1]) + \
|
| |
'::' + tc_name
|
| |
if 'call' in rep.when:
|
| |
fixes issue #5
Signed-off-by: Niranjan M.R mrniranjan@redhat.com