@@ -294,6 +294,19 @@ def test_parse_headers_longline(parser: Any) -> None:
294
294
parser .feed_data (text )
295
295
296
296
297
+ @pytest .fixture
298
+ def xfail_c_parser_status (request ) -> None :
299
+ if isinstance (request .getfixturevalue ("parser" ), HttpRequestParserPy ):
300
+ return
301
+ request .node .add_marker (
302
+ pytest .mark .xfail (
303
+ reason = "Regression test for Py parser. May match C behaviour later." ,
304
+ raises = http_exceptions .BadStatusLine ,
305
+ )
306
+ )
307
+
308
+
309
+ @pytest .mark .usefixtures ("xfail_c_parser_status" )
297
310
def test_parse_unusual_request_line (parser ) -> None :
298
311
if not isinstance (response , HttpResponseParserPy ):
299
312
pytest .xfail ("Regression test for Py parser. May match C behaviour later." )
@@ -632,9 +645,6 @@ def test_invalid_header_spacing(parser, pad1: bytes, pad2: bytes, hdr: bytes) ->
632
645
if pad1 == pad2 == b"" and hdr != b"" :
633
646
# one entry in param matrix is correct: non-empty name, not padded
634
647
expectation = nullcontext ()
635
- if pad1 == pad2 == hdr == b"" :
636
- if not isinstance (response , HttpResponseParserPy ):
637
- pytest .xfail ("Regression test for Py parser. May match C behaviour later." )
638
648
with expectation :
639
649
parser .feed_data (text )
640
650
@@ -815,9 +825,20 @@ def test_http_request_upgrade(parser: Any) -> None:
815
825
assert tail == b"some raw data"
816
826
817
827
828
+ @pytest .fixture
829
+ def xfail_c_parser_url (request ) -> None :
830
+ if isinstance (request .getfixturevalue ("parser" ), HttpRequestParserPy ):
831
+ return
832
+ request .node .add_marker (
833
+ pytest .mark .xfail (
834
+ reason = "Regression test for Py parser. May match C behaviour later." ,
835
+ raises = http_exceptions .InvalidURLError ,
836
+ )
837
+ )
838
+
839
+
840
+ @pytest .mark .usefixtures ("xfail_c_parser_url" )
818
841
def test_http_request_parser_utf8_request_line (parser ) -> None :
819
- if not isinstance (response , HttpResponseParserPy ):
820
- pytest .xfail ("Regression test for Py parser. May match C behaviour later." )
821
842
messages , upgrade , tail = parser .feed_data (
822
843
# note the truncated unicode sequence
823
844
b"GET /P\xc3 \xbc nktchen\xa0 \xef \xb7 HTTP/1.1\r \n " +
@@ -837,7 +858,9 @@ def test_http_request_parser_utf8_request_line(parser) -> None:
837
858
assert msg .compression is None
838
859
assert not msg .upgrade
839
860
assert not msg .chunked
840
- assert msg .url .path == URL ("/P%C3%BCnktchen\udca0 \udcef \udcb7 " ).path
861
+ # python HTTP parser depends on Cython and CPython URL to match
862
+ # .. but yarl.URL("/abs") is not equal to URL.build(path="/abs"), see #6409
863
+ assert msg .url == URL .build (path = "/Pünktchen\udca0 \udcef \udcb7 " , encoded = True )
841
864
842
865
843
866
def test_http_request_parser_utf8 (parser ) -> None :
0 commit comments