@echo off
REM 获取当前日期 20240423
set "current_date=%date:~0,4%%date:~5,2%%date:~8,2%"
REM set "current_time=%time:~0,2%%time:~3,2%%time:~6,2%"
REM 获取当前时间 094205
set "hour=%time:~0,2%"
set "minute=%time:~3,2%"
set "second=%time:~6,2%"
REM 如果小时小于10,只取第二位并在前面补0
if %hour% lss 10 (set "hour=0%time:~1,1%")
set "current_time=%hour%%minute%%second%"
REM 创建带有时间戳的完整文件夹路径
set "folder_path=F:\pythonScript\pythonProject\AI\VisionCube\VisionCubeTest\result\%current_date%"
if not exist "%folder_path%" mkdir "%folder_path%"
REM 设置 pytest 执行的文件夹目录
set "pytest_rootdir=F:\pythonScript\pythonProject\AI\VisionCube\VisionCubeTest"
REM 将 pytest 结果输出到生成的文件夹中
set "result_file=%folder_path%\test_%current_time%.html"
pytest --rootdir="%pytest_rootdir%" --tb=no --html="%result_file%"
遇到的问题:
电脑系统小于10的时间获取会显示成空格数字,如 9,所以增加了相应的过滤处理,否则文件夹中有空格