Skip to content

Commit 8ecb86f

Browse files
Add test for request params behavior changes (#3364) (#3440)
Co-authored-by: Tom Christie <[email protected]>
1 parent 0cb7e5a commit 8ecb86f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Our revised [SSL documentation](docs/advanced/ssl.md) covers how to implement th
2828
* Ensure `certifi` and `httpcore` are only imported if required. (#3377)
2929
* Treat `socks5h` as a valid proxy scheme. (#3178)
3030
* Cleanup `Request()` method signature in line with `client.request()` and `httpx.request()`. (#3378)
31+
* Bugfix: When passing `params={}`, always strictly update rather than merge with an existing querystring. (#3364)
3132

3233
## 0.27.2 (27th August, 2024)
3334

tests/models/test_requests.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,16 @@ def content() -> typing.Iterator[bytes]:
226226
request.read()
227227
pickle_request = pickle.loads(pickle.dumps(request))
228228
assert pickle_request.content == b"test 123"
229+
230+
231+
def test_request_params():
232+
request = httpx.Request("GET", "http://example.com", params={})
233+
assert str(request.url) == "http://example.com"
234+
235+
request = httpx.Request(
236+
"GET", "http://example.com?c=3", params={"a": "1", "b": "2"}
237+
)
238+
assert str(request.url) == "http://example.com?a=1&b=2"
239+
240+
request = httpx.Request("GET", "http://example.com?a=1", params={})
241+
assert str(request.url) == "http://example.com"

0 commit comments

Comments
 (0)