Skip to content

Commit 6f3fa39

Browse files
authored
add name option to link_annotation (#15)
1 parent 8239e64 commit 6f3fa39

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

python_testspace_xml/testspace_xml.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ def add_string_buffer_annotation(self, name, level='info', description='',
161161
self.annotations.append(fa)
162162
return fa
163163

164-
def add_link_annotation(self, level='info', description='', path=None):
165-
fa = Annotation(path, level, description)
164+
def add_link_annotation(self, path, level='info', description='', name=None):
165+
if name is None:
166+
name = path
167+
fa = Annotation(name, level, description)
166168
fa.set_link_annotation(path)
167169
self.annotations.append(fa)
168170
return fa
@@ -231,8 +233,10 @@ def add_string_buffer_annotation(self, name, level='info', description='',
231233
self.annotations.append(fa)
232234
return fa
233235

234-
def add_link_annotation(self, level='info', description='', path=None):
235-
fa = Annotation(path, level, description)
236+
def add_link_annotation(self, path, level='info', description='', name=None):
237+
if name is None:
238+
name = path
239+
fa = Annotation(name, level, description)
236240
fa.set_link_annotation(path)
237241
self.annotations.append(fa)
238242
return fa
@@ -320,6 +324,6 @@ def __init__(self):
320324
def get_root_suite(self):
321325
return self
322326

323-
def write_xml(self, outfile=None, to_pretty=False):
327+
def write_xml(self, out_file=None, to_pretty=False):
324328
writer = XmlWriter(self)
325-
writer.write(outfile, to_pretty)
329+
writer.write(out_file, to_pretty)

tests/test_testspace_report_xsd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def setup_class(cls):
3333
testspace_report.add_test_suite(suite)
3434

3535
example_suite = testspace_report.get_or_add_test_suite('Example Suite')
36-
example_suite.add_link_annotation(path='https://help.testspace.com')
36+
example_suite.add_link_annotation('https://help.testspace.com')
37+
example_suite.add_link_annotation('https://testspace.com', name='Testspace.com')
3738
example_suite.add_string_buffer_annotation(
3839
'Suite string annotation as file', string_buffer=cls.string_buffer)
3940
example_suite.add_text_annotation(
@@ -54,7 +55,7 @@ def setup_class(cls):
5455
test_case.add_file_annotation('report_v1.xsd', file_path='/report_v1.xsd')
5556
test_case.add_string_buffer_annotation(
5657
'Case string annotation as file', string_buffer=cls.string_buffer)
57-
test_case.add_link_annotation(path=r'\\machine/public')
58+
test_case.add_link_annotation(r'\\machine/public')
5859
test_case.add_info_annotation(cls.annotation_tuple[0][2])
5960
test_case.add_error_annotation(cls.annotation_tuple[1][2])
6061
test_case.add_warning_annotation(cls.annotation_tuple[2][2])
@@ -97,7 +98,7 @@ def test_testsuites_order(self):
9798

9899
def test_number_testsuite_annotations(self):
99100
test_suites = self.testspace_xml_root.xpath("//test_suite/annotation")
100-
assert len(test_suites) is 5
101+
assert len(test_suites) is 6
101102

102103
def test_testsuite_duration(self):
103104
suite_element = self.testspace_xml_root.xpath("//test_suite[@duration]")

0 commit comments

Comments
 (0)