Moving test cases into 'test_url.py' (#2982)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Moving test cases into 'test_url.py' * Move test_url to test_basic_url * Linting * Move TypeError test case. Move basic httpx.URL cases. * Linting * Merge invalid URL cases * Move percent encoding test cases * Move remaining test cases * Linting * Add missing test cases
authored by Tom Christie · committed by GitHub · parent 724eced · Browse files · 2 files·+325 added−313 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+325 added−313 removed
- tests:+325 added−313 removed
Provenance
- Commit
5b5f6d8- Tree
1372ecb- Author
Tom Christie <tom@tomchristie.com>- Committer
GitHub <noreply@github.com>- Parent
724eced
2 files changed+325 added−313 removed
modified:tests/models/test_url.py+325 added-28 removed
1 import pytest2 3 import httpx4 5+# Tests for `httpx.URL` instantiation and property accessors.6 7+6-def test_url():8+def test_basic_url():9+ url = httpx.URL("https://www.example.com/")10+11+ assert url.scheme == "https"12+ assert url.userinfo == b""13+ assert url.netloc == b"www.example.com"14+ assert url.host == "www.example.com"15+ assert url.port is None16+ assert url.path == "/"17+ assert url.query == b""18+ assert url.fragment == ""19+20+ assert str(url) == "https://www.example.com/"21+ assert repr(url) == "URL('https://www.example.com/')"22+23+24+def test_complete_url():25 url = httpx.URL("https://example.org:123/path/to/somewhere?abc=123#anchor")26 assert url.scheme == "https"27 assert url.host == "example.org"28 assert url.port == 12329 assert url.path == "/path/to/somewhere"30 assert url.query == b"abc=123"31 assert url.raw_path == b"/path/to/somewhere?abc=123"32 assert url.fragment == "anchor"33+34+ assert str(url) == "https://example.org:123/path/to/somewhere?abc=123#anchor"35 assert (36 repr(url) == "URL('https://example.org:123/path/to/somewhere?abc=123#anchor')"37 )38 19- new = url.copy_with(scheme="http", port=None)20- assert new == httpx.URL("http://example.org/path/to/somewhere?abc=123#anchor")21- assert new.scheme == "http"39 23-40 def test_url_with_empty_query():41 """42 URLs with and without a trailing `?` but an empty query component43 should preserve the information on the raw path.8 unmodified lines52 assert url.query == b""53 assert url.raw_path == b"/path?"54 55 56+def test_url_no_scheme():57+ url = httpx.URL("://example.com")58+ assert url.scheme == ""59+ assert url.host == "example.com"60+ assert url.path == "/"61+62+63+def test_url_no_authority():64+ url = httpx.URL("http://")65+ assert url.scheme == "http"66+ assert url.host == ""67+ assert url.path == "/"68+69+70+# Tests for percent encoding across path, query, and fragment...71+72+73+def test_path_percent_encoding():74+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS75+ url = httpx.URL("https://example.com/!$&'()*+,;= abc ABC 123 :/[]@")76+ assert url.raw_path == b"/!$&'()*+,;=%20abc%20ABC%20123%20:/[]@"77+ assert url.path == "/!$&'()*+,;= abc ABC 123 :/[]@"78+ assert url.query == b""79+ assert url.fragment == ""80+81+82+def test_query_percent_encoding():83+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS84+ url = httpx.URL("https://example.com/?!$&'()*+,;= abc ABC 123 :/[]@" + "?")85+ assert url.raw_path == b"/?!$&'()*+,;=%20abc%20ABC%20123%20:%2F[]@?"86+ assert url.path == "/"87+ assert url.query == b"!$&'()*+,;=%20abc%20ABC%20123%20:%2F[]@?"88+ assert url.fragment == ""89+90+91+def test_fragment_percent_encoding():92+ # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS93+ url = httpx.URL("https://example.com/#!$&'()*+,;= abc ABC 123 :/[]@" + "?#")94+ assert url.raw_path == b"/"95+ assert url.path == "/"96+ assert url.query == b""97+ assert url.fragment == "!$&'()*+,;= abc ABC 123 :/[]@?#"98+99+100 def test_url_query_encoding():101 """102 URL query parameters should use '%20' to encoding spaces,103 and should treat '/' as a safe character. This behaviour differs15 unmodified lines119 assert url.query == b""120 assert url.raw_path == b"/path%20to%20somewhere"121 122 63-def test_url_raw_compatibility():64- url = httpx.URL("https://www.example.com/path")65- scheme, host, port, raw_path = url.raw123+def test_url_params():124+ url = httpx.URL("https://example.org:123/path/to/somewhere", params={"a": "123"})125+ assert str(url) == "https://example.org:123/path/to/somewhere?a=123"126+ assert url.params == httpx.QueryParams({"a": "123"})127 67- assert scheme == b"https"68- assert host == b"www.example.com"69- assert port is None70- assert raw_path == b"/path"128+ url = httpx.URL(129+ "https://example.org:123/path/to/somewhere?b=456", params={"a": "123"}130+ )131+ assert str(url) == "https://example.org:123/path/to/somewhere?a=123"132+ assert url.params == httpx.QueryParams({"a": "123"})133 134 135+# Tests for different host types136+137+138+def test_url_valid_host():139+ url = httpx.URL("https://example.com/")140+ assert url.host == "example.com"141+142+143+def test_url_normalized_host():144+ url = httpx.URL("https://EXAMPLE.com/")145+ assert url.host == "example.com"146+147+148+def test_url_ipv4_like_host():149+ """rare host names used to quality as IPv4"""150+ url = httpx.URL("https://023b76x43144/")151+ assert url.host == "023b76x43144"152+153+154+# Tests for different port types155+156+157+def test_url_valid_port():158+ url = httpx.URL("https://example.com:123/")159+ assert url.port == 123160+161+162+def test_url_normalized_port():163+ # If the port matches the scheme default it is normalized to None.164+ url = httpx.URL("https://example.com:443/")165+ assert url.port is None166+167+73-def test_url_invalid():168+def test_url_invalid_port():169+ with pytest.raises(httpx.InvalidURL) as exc:170+ httpx.URL("https://example.com:abc/")171+ assert str(exc.value) == "Invalid port: 'abc'"172+173+174+# Tests for path handling175+176+177+def test_url_normalized_path():178+ url = httpx.URL("https://example.com/abc/def/../ghi/./jkl")179+ assert url.path == "/abc/ghi/jkl"180+181+182+def test_url_escaped_path():183+ url = httpx.URL("https://example.com/ /🌟/")184+ assert url.raw_path == b"/%20/%F0%9F%8C%9F/"185+186+187+def test_url_leading_dot_prefix_on_absolute_url():188+ url = httpx.URL("https://example.com/../abc")189+ assert url.path == "/abc"190+191+192+def test_url_leading_dot_prefix_on_relative_url():193+ url = httpx.URL("../abc")194+ assert url.path == "../abc"195+196+197+# Tests for optional percent encoding198+199+200+def test_param_requires_encoding():201+ url = httpx.URL("http://webservice", params={"u": "with spaces"})202+ assert str(url) == "http://webservice?u=with%20spaces"203+204+205+def test_param_does_not_require_encoding():206+ url = httpx.URL("http://webservice", params={"u": "with%20spaces"})207+ assert str(url) == "http://webservice?u=with%20spaces"208+209+210+def test_param_with_existing_escape_requires_encoding():211+ url = httpx.URL("http://webservice", params={"u": "http://example.com?q=foo%2Fa"})212+ assert str(url) == "http://webservice?u=http%3A%2F%2Fexample.com%3Fq%3Dfoo%252Fa"213+214+215+# Tests for invalid URLs216+217+218+def test_url_invalid_hostname():219 """220 Ensure that invalid URLs raise an `httpx.InvalidURL` exception.221 """222 with pytest.raises(httpx.InvalidURL):223 httpx.URL("https://😇/")224 225 226+def test_url_excessively_long_url():227+ with pytest.raises(httpx.InvalidURL) as exc:228+ httpx.URL("https://www.example.com/" + "x" * 100_000)229+ assert str(exc.value) == "URL too long"230+231+232+def test_url_excessively_long_component():233+ with pytest.raises(httpx.InvalidURL) as exc:234+ httpx.URL("https://www.example.com", path="/" + "x" * 100_000)235+ assert str(exc.value) == "URL component 'path' too long"236+237+238+def test_url_non_printing_character_in_url():239+ with pytest.raises(httpx.InvalidURL) as exc:240+ httpx.URL("https://www.example.com/\n")241+ assert str(exc.value) == "Invalid non-printable ASCII character in URL"242+243+244+def test_url_non_printing_character_in_component():245+ with pytest.raises(httpx.InvalidURL) as exc:246+ httpx.URL("https://www.example.com", path="/\n")247+ assert (248+ str(exc.value)249+ == "Invalid non-printable ASCII character in URL component 'path'"250+ )251+252+253+# Test for url components254+255+256+def test_url_with_components():257+ url = httpx.URL(scheme="https", host="www.example.com", path="/")258+259+ assert url.scheme == "https"260+ assert url.userinfo == b""261+ assert url.host == "www.example.com"262+ assert url.port is None263+ assert url.path == "/"264+ assert url.query == b""265+ assert url.fragment == ""266+267+ assert str(url) == "https://www.example.com/"268+269+270+def test_urlparse_with_invalid_component():271+ with pytest.raises(TypeError) as exc:272+ httpx.URL(scheme="https", host="www.example.com", incorrect="/")273+ assert str(exc.value) == "'incorrect' is an invalid keyword argument for URL()"274+275+276+def test_urlparse_with_invalid_scheme():277+ with pytest.raises(httpx.InvalidURL) as exc:278+ httpx.URL(scheme="~", host="www.example.com", path="/")279+ assert str(exc.value) == "Invalid URL component 'scheme'"280+281+282+def test_urlparse_with_invalid_path():283+ with pytest.raises(httpx.InvalidURL) as exc:284+ httpx.URL(scheme="https", host="www.example.com", path="abc")285+ assert str(exc.value) == "For absolute URLs, path must be empty or begin with '/'"286+287+ with pytest.raises(httpx.InvalidURL) as exc:288+ httpx.URL(path="//abc")289+ assert (290+ str(exc.value)291+ == "URLs with no authority component cannot have a path starting with '//'"292+ )293+294+ with pytest.raises(httpx.InvalidURL) as exc:295+ httpx.URL(path=":abc")296+ assert (297+ str(exc.value)298+ == "URLs with no scheme component cannot have a path starting with ':'"299+ )300+301+302+def test_url_with_relative_path():303+ # This path would be invalid for an absolute URL, but is valid as a relative URL.304+ url = httpx.URL(path="abc")305+ assert url.path == "abc"306+307+308+# Tests for `httpx.URL` python built-in operators.309+310+311 def test_url_eq_str():312 """83- Ensure that `httpx.URL` supports the equality operator,84- and can be compared against plain strings.313+ Ensure that `httpx.URL` supports the equality operator.314 """315 url = httpx.URL("https://example.org:123/path/to/somewhere?abc=123#anchor")316 assert url == "https://example.org:123/path/to/somewhere?abc=123#anchor"317 assert str(url) == url12 unmodified lines330 331 assert all(url in urls for url in url_set)332 333 334+# Tests for TypeErrors when instantiating `httpx.URL`.335+336+337 def test_url_invalid_type():338 """339 Ensure that invalid types on `httpx.URL()` raise a `TypeError`.340 """4 unmodified lines345 with pytest.raises(TypeError):346 httpx.URL(ExternalURLClass()) # type: ignore347 348 117-# Tests for `QueryParams`.349+def test_url_with_invalid_component():350+ with pytest.raises(TypeError) as exc:351+ httpx.URL(scheme="https", host="www.example.com", incorrect="/")352+ assert str(exc.value) == "'incorrect' is an invalid keyword argument for URL()"353 354 120-def test_url_params():121- url = httpx.URL("https://example.org:123/path/to/somewhere", params={"a": "123"})122- assert str(url) == "https://example.org:123/path/to/somewhere?a=123"123- assert url.params == httpx.QueryParams({"a": "123"})124-125- url = httpx.URL(126- "https://example.org:123/path/to/somewhere?b=456", params={"a": "123"}127- )128- assert str(url) == "https://example.org:123/path/to/somewhere?a=123"129- assert url.params == httpx.QueryParams({"a": "123"})130-131-355 # Tests for `URL.join()`.356 357 358 def test_url_join():84 unmodified lines443 444 # Tests for `URL.copy_with()`.445 446 447+def test_copy_with():448+ url = httpx.URL("https://www.example.com/")449+ assert str(url) == "https://www.example.com/"450+451+ url = url.copy_with()452+ assert str(url) == "https://www.example.com/"453+454+ url = url.copy_with(scheme="http")455+ assert str(url) == "http://www.example.com/"456+457+ url = url.copy_with(netloc=b"example.com")458+ assert str(url) == "http://example.com/"459+460+ url = url.copy_with(path="/abc")461+ assert str(url) == "http://example.com/abc"462+463+464 def test_url_copywith_authority_subcomponents():465 copy_with_kwargs = {466 "username": "username",467 "password": "password",196 unmodified lines664 assert url.scheme == scheme665 assert url.port == port666 667 668+def test_url_unescaped_idna_host():669+ url = httpx.URL("https://中国.icom.museum/")670+ assert url.raw_host == b"xn--fiqs8s.icom.museum"671+672+673+def test_url_escaped_idna_host():674+ url = httpx.URL("https://xn--fiqs8s.icom.museum/")675+ assert url.raw_host == b"xn--fiqs8s.icom.museum"676+677+678+def test_url_invalid_idna_host():679+ with pytest.raises(httpx.InvalidURL) as exc:680+ httpx.URL("https://☃.com/")681+ assert str(exc.value) == "Invalid IDNA hostname: '☃.com'"682+683+684+# Tests for IPv4 hostname support.685+686+687+def test_url_valid_ipv4():688+ url = httpx.URL("https://1.2.3.4/")689+ assert url.host == "1.2.3.4"690+691+692+def test_url_invalid_ipv4():693+ with pytest.raises(httpx.InvalidURL) as exc:694+ httpx.URL("https://999.999.999.999/")695+ assert str(exc.value) == "Invalid IPv4 address: '999.999.999.999'"696+697+698 # Tests for IPv6 hostname support.699 700 701 def test_ipv6_url():2 unmodified lines704 assert url.host == "::ffff:192.168.0.1"705 assert url.netloc == b"[::ffff:192.168.0.1]:5678"706 707 708+def test_url_valid_ipv6():709+ url = httpx.URL("https://[2001:db8::ff00:42:8329]/")710+ assert url.host == "2001:db8::ff00:42:8329"711+712+713+def test_url_invalid_ipv6():714+ with pytest.raises(httpx.InvalidURL) as exc:715+ httpx.URL("https://[2001]/")716+ assert str(exc.value) == "Invalid IPv6 address: '[2001]'"717+718+719 @pytest.mark.parametrize("host", ["[::ffff:192.168.0.1]", "::ffff:192.168.0.1"])720 def test_ipv6_url_from_raw_url(host):721 url = httpx.URL(scheme="https", host=host, port=443, path="/")722 16 unmodified lines739 740 assert url.host == "::ffff:192.168.0.1"741 assert url.netloc == b"[::ffff:192.168.0.1]:1234"742 assert str(url) == "http://[::ffff:192.168.0.1]:1234"743+744+745+# Test for deprecated API746+747+748+def test_url_raw_compatibility():749+ """750+ Test case for the (to-be-deprecated) `url.raw` accessor.751+ """752+ url = httpx.URL("https://www.example.com/path")753+ scheme, host, port, raw_path = url.raw754+755+ assert scheme == b"https"756+ assert host == b"www.example.com"757+ assert port is None758+ assert raw_path == b"/path"deleted:tests/test_urlparse.py-285 removed
1-import pytest2-3-import httpx4-5-6-def test_urlparse():7- url = httpx.URL("https://www.example.com/")8-9- assert url.scheme == "https"10- assert url.userinfo == b""11- assert url.netloc == b"www.example.com"12- assert url.host == "www.example.com"13- assert url.port is None14- assert url.path == "/"15- assert url.query == b""16- assert url.fragment == ""17-18- assert str(url) == "https://www.example.com/"19-20-21-def test_urlparse_no_scheme():22- url = httpx.URL("://example.com")23- assert url.scheme == ""24- assert url.host == "example.com"25- assert url.path == "/"26-27-28-def test_urlparse_no_authority():29- url = httpx.URL("http://")30- assert url.scheme == "http"31- assert url.host == ""32- assert url.path == "/"33-34-35-# Tests for different host types36-37-38-def test_urlparse_valid_host():39- url = httpx.URL("https://example.com/")40- assert url.host == "example.com"41-42-43-def test_urlparse_normalized_host():44- url = httpx.URL("https://EXAMPLE.com/")45- assert url.host == "example.com"46-47-48-def test_urlparse_ipv4_like_host():49- """rare host names used to quality as IPv4"""50- url = httpx.URL("https://023b76x43144/")51- assert url.host == "023b76x43144"52-53-54-def test_urlparse_valid_ipv4():55- url = httpx.URL("https://1.2.3.4/")56- assert url.host == "1.2.3.4"57-58-59-def test_urlparse_invalid_ipv4():60- with pytest.raises(httpx.InvalidURL) as exc:61- httpx.URL("https://999.999.999.999/")62- assert str(exc.value) == "Invalid IPv4 address: '999.999.999.999'"63-64-65-def test_urlparse_valid_ipv6():66- url = httpx.URL("https://[2001:db8::ff00:42:8329]/")67- assert url.host == "2001:db8::ff00:42:8329"68-69-70-def test_urlparse_invalid_ipv6():71- with pytest.raises(httpx.InvalidURL) as exc:72- httpx.URL("https://[2001]/")73- assert str(exc.value) == "Invalid IPv6 address: '[2001]'"74-75-76-def test_urlparse_unescaped_idna_host():77- url = httpx.URL("https://中国.icom.museum/")78- assert url.raw_host == b"xn--fiqs8s.icom.museum"79-80-81-def test_urlparse_escaped_idna_host():82- url = httpx.URL("https://xn--fiqs8s.icom.museum/")83- assert url.raw_host == b"xn--fiqs8s.icom.museum"84-85-86-def test_urlparse_invalid_idna_host():87- with pytest.raises(httpx.InvalidURL) as exc:88- httpx.URL("https://☃.com/")89- assert str(exc.value) == "Invalid IDNA hostname: '☃.com'"90-91-92-# Tests for different port types93-94-95-def test_urlparse_valid_port():96- url = httpx.URL("https://example.com:123/")97- assert url.port == 12398-99-100-def test_urlparse_normalized_port():101- # If the port matches the scheme default it is normalized to None.102- url = httpx.URL("https://example.com:443/")103- assert url.port is None104-105-106-def test_urlparse_invalid_port():107- with pytest.raises(httpx.InvalidURL) as exc:108- httpx.URL("https://example.com:abc/")109- assert str(exc.value) == "Invalid port: 'abc'"110-111-112-# Tests for path handling113-114-115-def test_urlparse_normalized_path():116- url = httpx.URL("https://example.com/abc/def/../ghi/./jkl")117- assert url.path == "/abc/ghi/jkl"118-119-120-def test_urlparse_escaped_path():121- url = httpx.URL("https://example.com/ /🌟/")122- assert url.raw_path == b"/%20/%F0%9F%8C%9F/"123-124-125-def test_urlparse_leading_dot_prefix_on_absolute_url():126- url = httpx.URL("https://example.com/../abc")127- assert url.path == "/abc"128-129-130-def test_urlparse_leading_dot_prefix_on_relative_url():131- url = httpx.URL("../abc")132- assert url.path == "../abc"133-134-135-# Tests for optional percent encoding136-137-138-def test_param_requires_encoding():139- url = httpx.URL("http://webservice", params={"u": "with spaces"})140- assert str(url) == "http://webservice?u=with%20spaces"141-142-143-def test_param_does_not_require_encoding():144- url = httpx.URL("http://webservice", params={"u": "with%20spaces"})145- assert str(url) == "http://webservice?u=with%20spaces"146-147-148-def test_param_with_existing_escape_requires_encoding():149- url = httpx.URL("http://webservice", params={"u": "http://example.com?q=foo%2Fa"})150- assert str(url) == "http://webservice?u=http%3A%2F%2Fexample.com%3Fq%3Dfoo%252Fa"151-152-153-# Tests for invalid URLs154-155-156-def test_urlparse_excessively_long_url():157- with pytest.raises(httpx.InvalidURL) as exc:158- httpx.URL("https://www.example.com/" + "x" * 100_000)159- assert str(exc.value) == "URL too long"160-161-162-def test_urlparse_excessively_long_component():163- with pytest.raises(httpx.InvalidURL) as exc:164- httpx.URL("https://www.example.com", path="/" + "x" * 100_000)165- assert str(exc.value) == "URL component 'path' too long"166-167-168-def test_urlparse_non_printing_character_in_url():169- with pytest.raises(httpx.InvalidURL) as exc:170- httpx.URL("https://www.example.com/\n")171- assert str(exc.value) == "Invalid non-printable ASCII character in URL"172-173-174-def test_urlparse_non_printing_character_in_component():175- with pytest.raises(httpx.InvalidURL) as exc:176- httpx.URL("https://www.example.com", path="/\n")177- assert (178- str(exc.value)179- == "Invalid non-printable ASCII character in URL component 'path'"180- )181-182-183-# Test for urlparse components184-185-186-def test_urlparse_with_components():187- url = httpx.URL(scheme="https", host="www.example.com", path="/")188-189- assert url.scheme == "https"190- assert url.userinfo == b""191- assert url.host == "www.example.com"192- assert url.port is None193- assert url.path == "/"194- assert url.query == b""195- assert url.fragment == ""196-197- assert str(url) == "https://www.example.com/"198-199-200-def test_urlparse_with_invalid_component():201- with pytest.raises(TypeError) as exc:202- httpx.URL(scheme="https", host="www.example.com", incorrect="/")203- assert str(exc.value) == "'incorrect' is an invalid keyword argument for URL()"204-205-206-def test_urlparse_with_invalid_scheme():207- with pytest.raises(httpx.InvalidURL) as exc:208- httpx.URL(scheme="~", host="www.example.com", path="/")209- assert str(exc.value) == "Invalid URL component 'scheme'"210-211-212-def test_urlparse_with_invalid_path():213- with pytest.raises(httpx.InvalidURL) as exc:214- httpx.URL(scheme="https", host="www.example.com", path="abc")215- assert str(exc.value) == "For absolute URLs, path must be empty or begin with '/'"216-217- with pytest.raises(httpx.InvalidURL) as exc:218- httpx.URL(path="//abc")219- assert (220- str(exc.value)221- == "URLs with no authority component cannot have a path starting with '//'"222- )223-224- with pytest.raises(httpx.InvalidURL) as exc:225- httpx.URL(path=":abc")226- assert (227- str(exc.value)228- == "URLs with no scheme component cannot have a path starting with ':'"229- )230-231-232-def test_urlparse_with_relative_path():233- # This path would be invalid for an absolute URL, but is valid as a relative URL.234- url = httpx.URL(path="abc")235- assert url.path == "abc"236-237-238-# Tests for accessing and modifying `urlparse` results.239-240-241-def test_copy_with():242- url = httpx.URL("https://www.example.com/")243- assert str(url) == "https://www.example.com/"244-245- url = url.copy_with()246- assert str(url) == "https://www.example.com/"247-248- url = url.copy_with(scheme="http")249- assert str(url) == "http://www.example.com/"250-251- url = url.copy_with(netloc=b"example.com")252- assert str(url) == "http://example.com/"253-254- url = url.copy_with(path="/abc")255- assert str(url) == "http://example.com/abc"256-257-258-# Tests for percent encoding across path, query, and fragement...259-260-261-def test_path_percent_encoding():262- # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS263- url = httpx.URL("https://example.com/!$&'()*+,;= abc ABC 123 :/[]@")264- assert url.raw_path == b"/!$&'()*+,;=%20abc%20ABC%20123%20:/[]@"265- assert url.path == "/!$&'()*+,;= abc ABC 123 :/[]@"266- assert url.query == b""267- assert url.fragment == ""268-269-270-def test_query_percent_encoding():271- # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS272- url = httpx.URL("https://example.com/?!$&'()*+,;= abc ABC 123 :/[]@" + "?")273- assert url.raw_path == b"/?!$&'()*+,;=%20abc%20ABC%20123%20:%2F[]@?"274- assert url.path == "/"275- assert url.query == b"!$&'()*+,;=%20abc%20ABC%20123%20:%2F[]@?"276- assert url.fragment == ""277-278-279-def test_fragment_percent_encoding():280- # Test percent encoding for SUB_DELIMS ALPHA NUM and allowable GEN_DELIMS281- url = httpx.URL("https://example.com/#!$&'()*+,;= abc ABC 123 :/[]@" + "?#")282- assert url.raw_path == b"/"283- assert url.path == "/"284- assert url.query == b""285- assert url.fragment == "!$&'()*+,;= abc ABC 123 :/[]@?#"