88def 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
2025class 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