Skip to content

Commit f309584

Browse files
committed
requests: Add tests for query and anchor in URL.
These new tests would have failed prior to the parent commit. Signed-off-by: Damien George <damien@micropython.org>
1 parent fea2adb commit f309584

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

python-ecosys/requests/test_requests.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ def test_simple_get():
5858
), format_message(response)
5959

6060

61+
def test_get_query_anchor():
62+
response = requests.request("GET", "http://example.com?query")
63+
assert response.raw._write_buffer.getvalue() == (
64+
b"GET /?query HTTP/1.1\r\nConnection: close\r\nHost: example.com\r\n\r\n"
65+
), format_message(response)
66+
67+
response = requests.request("GET", "http://example.com#anchor")
68+
assert response.raw._write_buffer.getvalue() == (
69+
b"GET /#anchor HTTP/1.1\r\nConnection: close\r\nHost: example.com\r\n\r\n"
70+
), format_message(response)
71+
72+
6173
def test_get_auth():
6274
response = requests.request(
6375
"GET", "http://example.com", auth=("test-username", "test-password")
@@ -312,6 +324,7 @@ def test_redirect_relative():
312324

313325

314326
test_simple_get()
327+
test_get_query_anchor()
315328
test_get_auth()
316329
test_get_custom_header()
317330
test_post_json()

0 commit comments

Comments
 (0)