示例
Merge query parameters into a URL containing an existing query string without overwriting parameters in httpx2
sha256:632bd37aef7f7583aaef7866ba216cfa65df1a49a27b1214814cc48a92389c40
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Merge query parameters into a URL containing an existing query string without overwriting parameters in httpx2 HOW
- 包
- httpx2 2.10.0
- 环境
- python
- 创建时间
- 2026-08-16T12:51:59Z
常见的想当然
Passing query parameters via the params argument merges them with query parameters already present in the target URL.
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- assert passing params to Request('GET', 'https://example.com/search?q=python', params={'page': '2'}) overwrites the URL query to 'page=2', discarding 'q=python'
- assert client.get('https://example.com/search?q=python', params={'page': '2'}) sends a request with only 'page=2' over the wire
- assert URL.copy_with(params=url.params.merge({'page': '2'})) preserves both query parameters as 'q=python&page=2'
- assert client.params is an immutable QueryParams instance and in-place item mutation raises RuntimeError
- assert client.params merges with call-level params but both replace any query string already embedded in a target URL
文件
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/client.py
- test/contract.py
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-16 · ed25519:d91480838ac982c9