@@ -37,11 +37,25 @@ class Cells:
3737        def  __init__ (self ):
3838            self ._html  =  {}
3939
40+         def  __delitem__ (self , key ):
41+             # This means the item should be removed 
42+             self ._html  =  None 
43+ 
4044        @property  
4145        def  html (self ):
4246            return  self ._html 
4347
4448        def  insert (self , index , html ):
49+             # backwards-compat 
50+             if  not  isinstance (html , str ):
51+                 if  html .__module__ .startswith ("py." ):
52+                     warnings .warn (
53+                         "The 'py' module is deprecated and support " 
54+                         "will be removed in a future release." ,
55+                         DeprecationWarning ,
56+                     )
57+                 html  =  str (html )
58+                 html  =  html .replace ("col" , "data-column-type" )
4559            self ._html [index ] =  html 
4660
4761    class  Report :
@@ -219,6 +233,7 @@ def pytest_sessionstart(self, session):
219233
220234        header_cells  =  self .Cells ()
221235        session .config .hook .pytest_html_results_table_header (cells = header_cells )
236+ 
222237        self ._report .set_data ("resultsTableHeader" , header_cells .html )
223238
224239        self ._report .set_data ("runningState" , "Started" )
@@ -258,25 +273,30 @@ def pytest_runtest_logreport(self, report):
258273        }
259274
260275        test_id  =  report .nodeid 
261-         if  report .when  !=  "call" :
276+         if  report .when  ==  "call" :
277+             row_cells  =  self .Cells ()
278+             self ._config .hook .pytest_html_results_table_row (
279+                 report = report , cells = row_cells 
280+             )
281+             if  row_cells .html  is  None :
282+                 return 
283+             data ["resultsTableRow" ] =  row_cells .html 
284+ 
285+             table_html  =  []
286+             self ._config .hook .pytest_html_results_table_html (
287+                 report = report , data = table_html 
288+             )
289+             data ["tableHtml" ] =  table_html 
290+         else :
262291            test_id  +=  f"::{ report .when }  
263292        data ["testId" ] =  test_id 
264293
265294        # Order here matters! 
266295        log  =  report .longreprtext  or  report .capstdout  or  "No log output captured." 
267296        data ["log" ] =  _handle_ansi (log )
268- 
269297        data ["result" ] =  _process_outcome (report )
270- 
271-         row_cells  =  self .Cells ()
272-         self ._config .hook .pytest_html_results_table_row (report = report , cells = row_cells )
273-         data ["resultsTableRow" ] =  row_cells .html 
274- 
275-         table_html  =  []
276-         self ._config .hook .pytest_html_results_table_html (report = report , data = table_html )
277-         data ["tableHtml" ] =  table_html 
278- 
279298        data ["extras" ] =  self ._process_extras (report , test_id )
299+ 
280300        self ._report .add_test (data )
281301        self ._generate_report ()
282302
0 commit comments