[英]Pytest integration with warcio
核心问题是在运行 pytest 时, warcio.capture_http
无法捕获任何响应和请求。
from warcio.capture_http import capture_http
import requests
def test_archive():
url = 'http://httpbin.org/get'
fn = 'is-it-captured.warc.gz'
with capture_http(fn):
requests.get(url=url)
if __name__ == '__main__':
test_archive()
如果上面的代码片段执行为python test_random.py
,那么 WARC output 符合预期; 文件大小大于 0 字节。 但是,如果代码作为pytest test_random.py
执行,则它无法捕获任何数据,并且生成的 WARC 文件为 0 字节。
在过去的两天里,我一直被困在这个问题上,无法弄清楚为什么会这样。 任何帮助,将不胜感激。
现在这个问题已经解决了。 错误是pytest
的dash
插件在修补之前加载。 必须禁用插件才能获得预期的行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.