1import datetime 2import shutil 3 4import pytest 5 6 7def pytest_addoption(parser: pytest.Parser) -> None: 8 parser.addoption("--use-existing-debugger", action="store_true", default=False, 9 help="Use the existing LLDB debugger (internal).") 10 parser.addoption("--gdb-remote", action="store", type=str, default=None, help="GDB remote session.") 11 parser.addoption("--extra-ignores", action="store", type=str, default='', help="Extra ignores for macros.") 12 13 14def pytest_sessionstart(session): 15 # Adjusting the terminal width to have enough space for the duration. 16 terminal_reporter = session.config.pluginmanager.getplugin("terminalreporter") 17 if terminal_reporter: 18 full_width = shutil.get_terminal_size().columns 19 custom_width = max(int(full_width) - len(' 0:00:00.000000'), 40) # Ensure a minimum width of 40 20 terminal_reporter._tw.fullwidth = custom_width 21 22 23def pytest_runtest_logreport(report: pytest.TestReport): 24 if report.when == "call": 25 # Log the duration of test on the fly. 26 formatted_duration = str(datetime.timedelta(seconds=report.duration)) 27 print(f' {formatted_duration}', end='') 28