Пример
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