File tree Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Original file line number Diff line number Diff line change 33from os import linesep as n
44from os import sep as p
55from pathlib import Path
6- from typing import cast
7- from xml .etree .ElementTree import Element
86
97import defusedxml .ElementTree as ET
108import schema_salad .ref_resolver
@@ -88,10 +86,10 @@ def test_category_in_junit_xml(tmp_path: Path) -> None:
8886 ]
8987 run_with_mock_cwl_runner (args )
9088 tree = ET .parse (junit_xml_report )
91- root = tree .getroot ()
92- category = cast (
93- Element , cast ( Element , root .find ("testsuite" )). find ( " testcase" )
94- ) .attrib ["class" ]
89+ assert ( root : = tree .getroot ()) is not None
90+ assert ( testsuite_el := root . find ( "testsuite" )) is not None
91+ assert ( testcase_el := testsuite_el .find ("testcase" )) is not None
92+ category = testcase_el .attrib ["class" ]
9593 assert category == "js, init_work_dir"
9694
9795
Original file line number Diff line number Diff line change 11from os import linesep as n
22from pathlib import Path
3- from typing import cast
4- from xml .etree .ElementTree import Element
53
64import defusedxml .ElementTree as ET
75
@@ -49,8 +47,8 @@ def test_short_name_in_junit_xml(tmp_path: Path) -> None:
4947 ]
5048 run_with_mock_cwl_runner (args )
5149 tree = ET .parse (junit_xml_report )
52- root = tree .getroot ()
53- category = cast (
54- Element , cast ( Element , root .find ("testsuite" )). find ( " testcase" )
55- ) .attrib ["file" ]
50+ assert ( root : = tree .getroot ()) is not None
51+ assert ( testsuite_el := root . find ( "testsuite" )) is not None
52+ assert ( testcase_el := testsuite_el .find ("testcase" )) is not None
53+ category = testcase_el .attrib ["file" ]
5654 assert category == "opt-error"
Original file line number Diff line number Diff line change 11import os
22from pathlib import Path
3- from typing import cast
4- from xml .etree .ElementTree import Element
53
64import defusedxml .ElementTree as ET
75import schema_salad .ref_resolver
@@ -31,20 +29,14 @@ def test_timeout_stderr_stdout(tmp_path: Path) -> None:
3129 assert "Test 1 timed out" in stderr
3230 tree = ET .parse (junit_xml_report )
3331 try :
34- root = tree .getroot ()
35- timeout_text = cast (
36- Element ,
37- cast (Element , cast (Element , root .find ("testsuite" )).find ("testcase" )).find (
38- "failure"
39- ),
40- ).text
41- timeout_stderr = cast (
42- Element ,
43- cast (Element , cast (Element , root .find ("testsuite" )).find ("testcase" )).find (
44- "system-err"
45- ),
46- ).text
32+ assert (root := tree .getroot ()) is not None
33+ assert (testsuite_el := root .find ("testsuite" )) is not None
34+ assert (testcase_el := testsuite_el .find ("testcase" )) is not None
35+ assert (failure_el := testcase_el .find ("failure" )) is not None
36+ timeout_text = failure_el .text
4737 assert timeout_text is not None and "Test timed out" in timeout_text
38+ assert (system_err_el := testcase_el .find ("system-err" )) is not None
39+ timeout_stderr = system_err_el .text
4840 assert timeout_stderr is not None and "timeout stderr" in timeout_stderr
4941 except AttributeError as e :
5042 print (junit_xml_report .read_text ())
You can’t perform that action at this time.
0 commit comments