Skip to content

Commit f7edf3d

Browse files
authored
remove suite roll up attributes (#4)
* remove suite roll up attributes * update tests
1 parent 69a63a9 commit f7edf3d

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

python_testspace_xml/testspace_xml.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ def __init__(self, name):
206206
self.is_root_suite = False
207207
self.name = name
208208
self.description = ''
209-
self.passed = 0
210-
self.failed = 0
211-
self.not_applicable = 0
212-
self.in_progress = 0
213209
self.start_time = ''
214210
self.test_cases = []
215211
self.custom_data = []
@@ -224,22 +220,9 @@ def clean_up(self):
224220
a.clean_up()
225221

226222
def add_test_case(self, tc):
227-
self.update_roll_ups(tc)
228223
self.test_cases.append(tc)
229224
return tc
230225

231-
def update_roll_ups(self, tc):
232-
if tc.status == 'passed':
233-
self.passed += 1
234-
elif tc.status == 'failed':
235-
self.failed += 1
236-
elif tc.status == 'not_applicable':
237-
self.not_applicable += 1
238-
elif tc.status == 'in_progress':
239-
self.in_progress += 1
240-
elif True:
241-
assert (False)
242-
243226
def get_or_add_suite(self, suite_name):
244227
if not suite_name:
245228
# write under root suite
@@ -311,10 +294,6 @@ def write_suite(self, parent_node, test_suite):
311294
suite_elem = self.dom.createElement('test_suite')
312295
suite_elem.setAttribute('name', test_suite.name)
313296
suite_elem.setAttribute('description', test_suite.description)
314-
suite_elem.setAttribute('passed', str(test_suite.passed))
315-
suite_elem.setAttribute('failed', str(test_suite.failed))
316-
suite_elem.setAttribute('not_applicable', str(test_suite.not_applicable))
317-
suite_elem.setAttribute('in_progress', str(test_suite.in_progress))
318297
suite_elem.setAttribute('start_time', str(test_suite.start_time))
319298
parent_node.appendChild(suite_elem)
320299

tests/test_TestspaceReport.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88
def create_simple_testspace_xml(self):
99
testspace_report = testspace_xml.TestspaceReport()
1010
example_suite = testspace_report.get_or_add_suite('Example Suite')
11-
test_case = testspace_xml.TestCase('test a', 'passed')
11+
test_case = testspace_xml.TestCase('passing case 1', 'passed')
12+
example_suite.add_test_case(test_case)
13+
test_case = testspace_xml.TestCase('passing case 2', 'passed')
14+
example_suite.add_test_case(test_case)
15+
test_case = testspace_xml.TestCase('failing case 1', 'failed')
1216
example_suite.add_test_case(test_case)
1317
testspace_report.xml_file('testspace.xml')
1418

1519
xml_file = open('testspace.xml', 'r')
1620
self.testspace_xml_string = xml_file.read()
1721
xml_file.close()
1822

23+
self.testspace_xml_root = etree.fromstring(self.testspace_xml_string)
1924

2025
class TestTestspaceXml:
2126
@pytest.fixture(autouse=True)
@@ -30,7 +35,16 @@ def teardown_class(cls):
3035
os.remove('testspace.xml')
3136

3237
def test_number_testcases(self):
33-
assert 'passed="1"' in self.testspace_xml_string
38+
test_cases = self.testspace_xml_root.xpath("//test_suite/test_case")
39+
assert len(test_cases) is 3
40+
41+
def test_number_passed_testcases(self):
42+
test_cases = self.testspace_xml_root.xpath("//test_suite/test_case[@status='passed']")
43+
assert len(test_cases) is 2
44+
45+
def test_number_failed_testcases(self):
46+
test_cases = self.testspace_xml_root.xpath("//test_suite/test_case[@status='failed']")
47+
assert len(test_cases) is 1
3448

3549
def test_validate_xsd(self):
3650
assert xml_validator(self.testspace_xml_string, 'tests/report_v1.xsd')

0 commit comments

Comments
 (0)