python - 使用日志记录时拆解中的 Pytest 错误
问题描述
当我运行我的测试时,如果我在它产生后使用 ctrl-c(键盘中断)取消它,它应该在产生语句之后继续运行代码。但是,如果我在启用日志记录的情况下运行它:
pytest test_logging_error.py --log-cli-level info
它会导致错误:
AttributeError: 'NoneType' object has no attribute 'resume_capturing'
它在记录消息“它在此处崩溃”后执行此操作,这是代码。
from time import sleep
import pytest
import logging
@pytest.fixture(scope="module")
def connection():
numbers = []
for i in range(10):
numbers.append(i)
yield numbers
logging.info("It crashes here")
for i in range(10):
print("foo")
def test_error(connection):
logging.info("Running a test")
sleep(10000)
如果我在产量后不记录或仅禁用记录就运行它,它运行良好并且拆解正确完成。
解决方案
这是一个实际的 pytest 错误,我相信https://github.com/pytest-dev/pytest/pull/4487修复了它(它刚刚被合并到 master 中)
但是由于https://github.com/pytest-dev/pytest/issues/4500中的错误报告,我们现在有一个最小的复制器,可以作为回归测试添加
如果问题得到解决,请通过 master 的 pytest 进行验证,如果问题得到解决,我会在找到时间时将测试添加到测试套件中。
谢谢:+1:
推荐阅读
- python - 读取每行非零元素的列号
- hibernate - Hibernate 5.2 Spring 4.3 MappingException:无法确定类型:sun.security.util.Password
- reactjs - Recharts 设置 Y 轴范围
- python - 如何使用 tkinter 按钮在条件下分别调用两个函数?
- codeigniter-3 - 如何在codeigniter中将发票数据插入数据库
- azure - 将 QueueClient.Create 转换为 MessagingFactory.CreateQueueClient
- javascript - 使用 Cordova 部署 android 构建后出现错误的字符
- c# - C# 线程池优先级
- mysql - MySQL 使用表名作为函数
- php - 检查PHP中两个字符串之间是否只有1个字符差异