99from py .xml import html # type: ignore
1010import io
1111import logging
12+ from bs4 import BeautifulSoup
13+ import atexit
1214
1315
1416@pytest .fixture (scope = "session" )
@@ -83,4 +85,29 @@ def pytest_collection_modifyitems(items):
8385 if hasattr (item , 'callspec' ):
8486 prompt = item .callspec .params .get ("prompt" )
8587 if prompt :
86- item ._nodeid = prompt # This controls how the test name appears in the report
88+ item ._nodeid = prompt # This controls how the test name appears in the report
89+
90+ def rename_duration_column ():
91+ report_path = os .path .abspath ("report.html" ) # or your report filename
92+ if not os .path .exists (report_path ):
93+ print ("Report file not found, skipping column rename." )
94+ return
95+
96+ with open (report_path , 'r' , encoding = 'utf-8' ) as f :
97+ soup = BeautifulSoup (f , 'html.parser' )
98+
99+ # Find and rename the header
100+ headers = soup .select ('table#results-table thead th' )
101+ for th in headers :
102+ if th .text .strip () == 'Duration' :
103+ th .string = 'Execution Time'
104+ #print("Renamed 'Duration' to 'Execution Time'")
105+ break
106+ else :
107+ print ("'Duration' column not found in report." )
108+
109+ with open (report_path , 'w' , encoding = 'utf-8' ) as f :
110+ f .write (str (soup ))
111+
112+ # Register this function to run after everything is done
113+ atexit .register (rename_duration_column )
0 commit comments