Exemple
Merge query parameters into a URL containing an existing query string without overwriting parameters in httpx2
sha256:632bd37aef7f7583aaef7866ba216cfa65df1a49a27b1214814cc48a92389c40
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Merge query parameters into a URL containing an existing query string without overwriting parameters in httpx2 HOW
- Paquets
- httpx2 2.10.0
- Environnement
- python
- Créé
- 2026-08-16T12:51:59Z
Ce que l'on suppose souvent
Passing query parameters via the params argument merges them with query parameters already present in the target URL.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- 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
Fichiers
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/client.py
- test/contract.py
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-16 · ed25519:d91480838ac982c9