可以使用pytest中的 CAPTURE_DIR 变量来指定日志目录。以下是示例代码:
import pytest
import os
@pytest.fixture(scope='session')
def capture_dir():
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'test-output'))
def run_tests():
# 使用 `CAPTURE_DIR` 变量来指定日志目录
args = ['-v', '--html=report.html', f"--capture-dir={capture_dir()}"]
errno = pytest.main(args=args)
return errno
if __name__ == '__main__':
errno = run_tests()
sys.exit(errno)
上一篇:anaconda在哪里输入命令