@@ -69,14 +69,37 @@ def pytest_exception_interact(node, call, report):
6969 """
7070 # call.excinfo is the captured exception of the call, if it raised as type ExceptionInfo.
7171 # call.excinfo.exconly() returns the exception as a string.
72- if call .excinfo and call .excinfo .typename != "AssertionError" :
73- ERRORS .append (
74- call .excinfo .exconly () + "\n Check Python Test Logs for more details."
75- )
72+ # See if it is during discovery or execution.
73+ # if discovery, then add the error to error logs.
74+ if type (report ) == pytest .CollectReport :
75+ if call .excinfo and call .excinfo .typename != "AssertionError" :
76+ ERRORS .append (
77+ call .excinfo .exconly () + "\n Check Python Test Logs for more details."
78+ )
79+ else :
80+ ERRORS .append (
81+ report .longreprtext + "\n Check Python Test Logs for more details."
82+ )
7683 else :
77- ERRORS .append (
78- report .longreprtext + "\n Check Python Test Logs for more details."
79- )
84+ # if execution, send this data that the given node failed.
85+ report_value = "failure"
86+ node_id = str (node .nodeid )
87+ if node_id not in collected_tests_so_far :
88+ collected_tests_so_far .append (node_id )
89+ item_result = create_test_outcome (
90+ node_id ,
91+ report_value ,
92+ "Test failed with exception" ,
93+ report .longreprtext ,
94+ )
95+ collected_test = testRunResultDict ()
96+ collected_test [node_id ] = item_result
97+ cwd = pathlib .Path .cwd ()
98+ execution_post (
99+ os .fsdecode (cwd ),
100+ "success" ,
101+ collected_test if collected_test else None ,
102+ )
80103
81104
82105def pytest_keyboard_interrupt (excinfo ):
@@ -183,6 +206,35 @@ def pytest_report_teststatus(report, config):
183206}
184207
185208
209+ def pytest_runtest_protocol (item , nextitem ):
210+ if item .own_markers :
211+ for marker in item .own_markers :
212+ # If the test is marked with skip then it will not hit the pytest_report_teststatus hook,
213+ # therefore we need to handle it as skipped here.
214+ skip_condition = False
215+ if marker .name == "skipif" :
216+ skip_condition = any (marker .args )
217+ if marker .name == "skip" or skip_condition :
218+ node_id = str (item .nodeid )
219+ report_value = "skipped"
220+ cwd = pathlib .Path .cwd ()
221+ if node_id not in collected_tests_so_far :
222+ collected_tests_so_far .append (node_id )
223+ item_result = create_test_outcome (
224+ node_id ,
225+ report_value ,
226+ None ,
227+ None ,
228+ )
229+ collected_test = testRunResultDict ()
230+ collected_test [node_id ] = item_result
231+ execution_post (
232+ os .fsdecode (cwd ),
233+ "success" ,
234+ collected_test if collected_test else None ,
235+ )
236+
237+
186238def pytest_sessionfinish (session , exitstatus ):
187239 """A pytest hook that is called after pytest has fulled finished.
188240
0 commit comments