@@ -897,3 +897,93 @@ def test_erase_all_with_port_cache_case2(dut):
897897 )
898898
899899 result .assert_outcomes (passed = 2 )
900+
901+
902+ def test_no_preserve_python_tests (testdir ):
903+ testdir .makepyfile (r"""
904+ def test_python_case(dut):
905+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
906+ """ )
907+
908+ testdir .runpytest (
909+ '-s' ,
910+ '--embedded-services' , 'esp,idf' ,
911+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
912+ '--log-cli-level' , 'DEBUG' ,
913+ '--junitxml' , 'report.xml' ,
914+ )
915+
916+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
917+
918+ assert junit_report .attrib ['tests' ] == '2'
919+ for testcase in junit_report .findall ('testcase' ):
920+ assert testcase .attrib ['is_unity_case' ] == '1'
921+
922+ def test_preserve_python_tests (testdir ):
923+ testdir .makepyfile (r"""
924+ def test_python_case(dut):
925+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
926+ """ )
927+
928+ testdir .runpytest (
929+ '-s' ,
930+ '--embedded-services' , 'esp,idf' ,
931+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
932+ '--log-cli-level' , 'DEBUG' ,
933+ '--junitxml' , 'report.xml' ,
934+ '--unity-test-report-mode' , 'merge' ,
935+ )
936+
937+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
938+
939+ assert junit_report .attrib ['tests' ] == '2'
940+ assert junit_report [0 ].attrib ['is_unity_case' ] == '0'
941+ for testcase in junit_report [1 :]:
942+ assert testcase .attrib ['is_unity_case' ] == '1'
943+
944+
945+ def test_preserve_python_tests_with_failures (testdir ):
946+ testdir .makepyfile (r"""
947+ def test_python_case(dut):
948+ dut.run_all_single_board_cases(name=["normal_case1", "normal_case2"])
949+ """ )
950+
951+ testdir .runpytest (
952+ '-s' ,
953+ '--embedded-services' , 'esp,idf' ,
954+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
955+ '--log-cli-level' , 'DEBUG' ,
956+ '--junitxml' , 'report.xml' ,
957+ '--unity-test-report-mode' , 'merge' ,
958+ )
959+
960+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
961+
962+ assert junit_report .attrib ['failures' ] == '1'
963+ assert junit_report [0 ].attrib ['is_unity_case' ] == '0' # Python test case is preserved
964+ assert junit_report [1 ].attrib ['is_unity_case' ] == '1' # C test case
965+ assert junit_report [1 ].find ('failure' ) is None # normal_case1 passed
966+ assert junit_report [2 ].attrib ['is_unity_case' ] == '1'
967+ assert junit_report [2 ].find ('failure' ) is not None # normal_case2 failed
968+
969+
970+ def test_python_func_attribute (testdir ):
971+ testdir .makepyfile (r"""
972+ def test_python_case(dut):
973+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
974+ """ )
975+
976+ testdir .runpytest (
977+ '-s' ,
978+ '--embedded-services' , 'esp,idf' ,
979+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
980+ '--log-cli-level' , 'DEBUG' ,
981+ '--junitxml' , 'report.xml' ,
982+ '--unity-test-report-mode' , 'merge' ,
983+ )
984+
985+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
986+
987+ assert junit_report [0 ].attrib ['is_unity_case' ] == '0' # Python test case
988+ for testcase in junit_report [1 :]:
989+ assert testcase .attrib ['is_unity_case' ] == '1' # Other test cases
0 commit comments