How to use responses with cachecontrol?
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- testing-qa
调研方向
首先使用 responses 0.25.8、CacheControl 0.14.2、requests 2.32.4 和 Python 3.12.6 运行提供的测试,然后将其与 responses 0.12.1 进行比较。跟踪 responses 如何处理 requests Session 及其适配器;当强制连接错误返回复现中所示的先前缓存的响应时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hey folks,
We're trying to update some libs and hit an odd issue with updating responses. Consider this test:
import responses
import requests
from cachecontrol import CacheControl
def get_client():
return CacheControl(requests.Session())
@responses.activate
def test_with_cachecontrol():
client = get_client()
responses.add(responses.GET, "http://test-website.com", body="Hello, world!")
response = client.get("http://test-website.com")
assert response.text == "Hello, world!"
# force a connection error. Though since we're cached, it should return the cached response.
responses.add(responses.GET, "http://test-website.com", body=ConnectionError())
response = client.get("http://test-website.com")
assert response.text == "Hello, world!"
(This is a simplified version of the test in our code, but should suffice.)
The gist here is we use responses to force a valid response, then after we try to force it to instead raise a ConnectionError. Normally this would lead to the cached version of the data coming back. However once we go to reponses==0.25.8 from where we previously were in responses=0.12.1 this no longer works. We get the ConnectionError raised instead of getting the cached response.
I think responses isn't running the adapters that are otherwise on the session anymore. Is there a way to still run them for this type of testing?
If it helps, heres some more info about dependencies:
CacheControl=0.14.2
requests=2.32.4
python 3.12.6 on Mac
- 主要语言
- Python
- 星标
- 4.3k
- 派生
- 389
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/responses 的其他 Issue
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")可能已有人在做 @mayureshsonawane17 于 26 天前认领。 未关闭Waiting for: Product Owner
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 3 天内回复
-
enhancement Waiting for: Product Owner
难度 4/5 3-5 天 新手友好度 35/100
getsentry/responses#783 · 1 条评论 · 3 个 reaction ·
维护者通常 3 天内回复
-
question
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 3 天内回复
-
enhancement question
难度 5/5 一周以上 新手友好度 30/100
维护者通常 3 天内回复
-
难度 3/5 1-2 天 新手友好度 45/100
getsentry/responses#765 · 1 条评论 ·
维护者通常 3 天内回复
查看 getsentry/responses 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
namespace operations
难度 1/5 1 小时以内 新手友好度 65/100
EclipseFdn/open-vsx.org#15057 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
FinanceFlash/unvibecode#349 ·
-
Mission statement: why this is free, in the README, Why This Exists and the wiki Home可能已有人在做 @ChiefGyk3D 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
vllm-project/vime#508 ·
维护者通常 4 天内回复