【发布时间】:2021-10-12 21:03:37
【问题描述】:
我的测试框架有以下结构
- Master_test_Class.py ---> 保存为冒烟和回归测试套件运行的通用测试用例
- Test_Smoke1.py 和 Test_Reg1.py --> 子类继承 Master_test_class.py
我在 pytest.ini 中为 INFO 启用了日志记录
[pytest]
log_cli = 1
log_cli_level = INFO
下面是我在 conftest.py 中的代码
def pytest_generate_tests(metafunc):
.....
logging.info("This is generated during the test collection !!!")
当我运行任何一个测试文件的测试时,日志会以 pytest.ini 中指定的格式打印两次,然后以红色打印一次
pytest -s Test_Reg1.py
我很迷茫,为什么日志信息会被打印两次。
【问题讨论】:
-
请分享记录器配置。
标签: python unit-testing logging pytest