Skip to content

Commit 3128c53

Browse files
authored
rename internal functions (#5)
1 parent f7edf3d commit 3128c53

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

python_testspace_xml/testspace_xml.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, name, value):
1818
self.name = name
1919
self.value = value
2020

21-
def write_xml(self, parent_element, dom):
21+
def _write_xml(self, parent_element, dom):
2222
d_elem = dom.createElement('custom_data')
2323
d_elem.setAttribute('name', self.name)
2424
cdata = dom.createCDATASection(self.value)
@@ -43,7 +43,7 @@ def add_comment(self, name, comment):
4343
comment = AnnotationComment(name, comment)
4444
self.comments.append(comment)
4545

46-
def clean_up(self):
46+
def _clean_up(self):
4747
pass
4848

4949

@@ -58,18 +58,18 @@ def __init__(self, file_path, level='info', description='',
5858
self.fileName = ntpath.basename(file_path)
5959
self.deleteFile = delete_file
6060

61-
def clean_up(self):
61+
def _clean_up(self):
6262
if self.deleteFile and os.path.isfile(self.filePath):
6363
os.remove(self.filePath)
6464

65-
def write_xml(self, parent_element, dom):
65+
def _write_xml(self, parent_element, dom):
6666
if not os.path.isfile(self.filePath):
6767
# write as a warning text annotation
6868
ta = TextAnnotation(self.name or self.fileName, self.level)
6969
ta.description = 'File: ' + self.filePath + ' not found.'
7070
for com in self.comments:
7171
ta.comments.append(com)
72-
ta.write_xml(parent_element, dom)
72+
ta._write_xml(parent_element, dom)
7373
return
7474

7575
# write as a file annotation
@@ -118,7 +118,7 @@ def __init__(self, name, level='info', description=''):
118118
Annotation.__init__(self, level, description)
119119
self.name = name
120120

121-
def write_xml(self, parent_element, dom):
121+
def _write_xml(self, parent_element, dom):
122122
# write as a file annotation to the root suite
123123
anno = dom.createElement("annotation")
124124
anno.setAttribute("description", XmlWriter.fix_line_ends(self.description))
@@ -149,9 +149,9 @@ def __init__(self, name, status='passed'):
149149
self.diagnostic_file = None
150150
self.meta_info = ""
151151

152-
def clean_up(self):
152+
def _clean_up(self):
153153
for a in self.annotations:
154-
a.clean_up()
154+
a._clean_up()
155155

156156
def set_description(self, description):
157157
self.description = description
@@ -211,13 +211,13 @@ def __init__(self, name):
211211
self.custom_data = []
212212
self.annotations = []
213213

214-
def clean_up(self):
214+
def _clean_up(self):
215215
for s in self.sub_suites:
216-
self.get_or_add_suite(s).clean_up()
216+
self.get_or_add_suite(s)._clean_up()
217217
for tc in self.test_cases:
218-
tc.clean_up()
218+
tc._clean_up()
219219
for a in self.annotations:
220-
a.clean_up()
220+
a._clean_up()
221221

222222
def add_test_case(self, tc):
223223
self.test_cases.append(tc)
@@ -273,7 +273,7 @@ def fix_line_ends(s):
273273

274274
def write(self, target_file_path=''):
275275
doc_elem = self.dom.documentElement
276-
self.write_suite(doc_elem, self.report.get_root_suite())
276+
self._write_suite(doc_elem, self.report.get_root_suite())
277277
if target_file_path:
278278
with open(target_file_path, 'w') as f:
279279
f.write(self.dom.toprettyxml())
@@ -282,12 +282,12 @@ def write(self, target_file_path=''):
282282
sys.stdout.write(self.dom.toxml())
283283
# print(self.dom.toprettyxml())
284284
# print(self.dom.toxml())
285-
self.clean_up()
285+
self._clean_up()
286286

287-
def clean_up(self):
288-
self.report.get_root_suite().clean_up()
287+
def _clean_up(self):
288+
self.report.get_root_suite()._clean_up()
289289

290-
def write_suite(self, parent_node, test_suite):
290+
def _write_suite(self, parent_node, test_suite):
291291
# don't explicitly add suite for root suite
292292
suite_elem = parent_node
293293
if not test_suite.is_root_suite:
@@ -298,19 +298,19 @@ def write_suite(self, parent_node, test_suite):
298298
parent_node.appendChild(suite_elem)
299299

300300
for a in test_suite.annotations:
301-
a.write_xml(suite_elem, self.dom)
301+
a._write_xml(suite_elem, self.dom)
302302

303303
for d in test_suite.custom_data:
304-
d.write_xml(suite_elem, self.dom)
304+
d._write_xml(suite_elem, self.dom)
305305

306306
for tc in test_suite.test_cases:
307-
self.write_test_case(suite_elem, tc)
307+
self._write_test_case(suite_elem, tc)
308308

309309
# write child suites, sort by name
310310
for ts in sorted(test_suite.sub_suites.keys()):
311-
self.write_suite(suite_elem, test_suite.sub_suites[ts])
311+
self._write_suite(suite_elem, test_suite.sub_suites[ts])
312312

313-
def write_test_case(self, parent_node, test_case):
313+
def _write_test_case(self, parent_node, test_case):
314314
elem_tc = self.dom.createElement('test_case')
315315

316316
elem_tc.setAttribute('name', test_case.name)
@@ -321,10 +321,10 @@ def write_test_case(self, parent_node, test_case):
321321
parent_node.appendChild(elem_tc)
322322

323323
for a in test_case.annotations:
324-
a.write_xml(elem_tc, self.dom)
324+
a._write_xml(elem_tc, self.dom)
325325

326326
for d in test_case.custom_data:
327-
d.write_xml(elem_tc, self.dom)
327+
d._write_xml(elem_tc, self.dom)
328328

329329

330330
class TestspaceReport(TestSuite):

tests/test_TestspaceReport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def create_simple_testspace_xml(self):
2222

2323
self.testspace_xml_root = etree.fromstring(self.testspace_xml_string)
2424

25+
2526
class TestTestspaceXml:
2627
@pytest.fixture(autouse=True)
2728
def setup_class(self):

0 commit comments

Comments
 (0)