@@ -247,3 +247,33 @@ def test_copy_with():
247247
248248 url = url .copy_with (path = "/abc" )
249249 assert str (url ) == "http://example.com/abc"
250+
251+
252+ # Tests for percent encoding across path, query, and fragement...
253+
254+
255+ def test_path_percent_encoding ():
256+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS
257+ url = httpx .URL ("https://example.com/!$&'()*+,;= abc ABC 123 :/[]@" )
258+ assert url .raw_path == b"/!$&'()*+,;=%20abc%20ABC%20123%20:/[]@"
259+ assert url .path == "/!$&'()*+,;= abc ABC 123 :/[]@"
260+ assert url .query == b""
261+ assert url .fragment == ""
262+
263+
264+ def test_query_percent_encoding ():
265+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS
266+ url = httpx .URL ("https://example.com/?!$&'()*+,;= abc ABC 123 :/[]@" + "?" )
267+ assert url .raw_path == b"/?!$&'()*+,;=%20abc%20ABC%20123%20:/[]@?"
268+ assert url .path == "/"
269+ assert url .query == b"!$&'()*+,;=%20abc%20ABC%20123%20:/[]@?"
270+ assert url .fragment == ""
271+
272+
273+ def test_fragment_percent_encoding ():
274+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS
275+ url = httpx .URL ("https://example.com/#!$&'()*+,;= abc ABC 123 :/[]@" + "?#" )
276+ assert url .raw_path == b"/"
277+ assert url .path == "/"
278+ assert url .query == b""
279+ assert url .fragment == "!$&'()*+,;= abc ABC 123 :/[]@?#"
0 commit comments