@@ -37,11 +37,25 @@ class Cells:
37
37
def __init__ (self ):
38
38
self ._html = {}
39
39
40
+ def __delitem__ (self , key ):
41
+ # This means the item should be removed
42
+ self ._html = None
43
+
40
44
@property
41
45
def html (self ):
42
46
return self ._html
43
47
44
48
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" )
45
59
self ._html [index ] = html
46
60
47
61
class Report :
@@ -219,6 +233,7 @@ def pytest_sessionstart(self, session):
219
233
220
234
header_cells = self .Cells ()
221
235
session .config .hook .pytest_html_results_table_header (cells = header_cells )
236
+
222
237
self ._report .set_data ("resultsTableHeader" , header_cells .html )
223
238
224
239
self ._report .set_data ("runningState" , "Started" )
@@ -258,25 +273,30 @@ def pytest_runtest_logreport(self, report):
258
273
}
259
274
260
275
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 :
262
291
test_id += f"::{ report .when } "
263
292
data ["testId" ] = test_id
264
293
265
294
# Order here matters!
266
295
log = report .longreprtext or report .capstdout or "No log output captured."
267
296
data ["log" ] = _handle_ansi (log )
268
-
269
297
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
-
279
298
data ["extras" ] = self ._process_extras (report , test_id )
299
+
280
300
self ._report .add_test (data )
281
301
self ._generate_report ()
282
302
0 commit comments