@@ -551,21 +551,41 @@ def test_parse_link_handles_deprecated_usage_properly() -> None:
551
551
assert "pkg1-2.0" in parsed_links [1 ].url
552
552
553
553
554
- @mock .patch ("pip._internal.index.collector.deprecated" )
555
- def test_parse_links_presents_deprecation_warning_on_non_html5_page (
556
- mock_deprecated : mock .Mock ,
554
+ def test_parse_links_presents_warning_on_missing_doctype (
555
+ caplog : pytest .LogCaptureFixture ,
557
556
) -> None :
558
557
html = b'<a href="/pkg1-1.0.tar.gz"></a><a href="/pkg1-2.0.tar.gz"></a>'
559
558
url = "https://example.com/simple/"
560
559
page = HTMLPage (html , encoding = None , url = url , cache_link_parsing = False )
561
560
562
- parsed_links = list (parse_links (page , use_deprecated_html5lib = False ))
561
+ with caplog .at_level (logging .WARN ):
562
+ parsed_links = list (parse_links (page , use_deprecated_html5lib = False ))
563
563
564
564
assert len (parsed_links ) == 2 , parsed_links
565
565
assert "pkg1-1.0" in parsed_links [0 ].url
566
566
assert "pkg1-2.0" in parsed_links [1 ].url
567
567
568
- mock_deprecated .assert_called_once ()
568
+ assert len (caplog .records ) == 1
569
+
570
+
571
+ def test_parse_links_presents_warning_on_html4_doctype (
572
+ caplog : pytest .LogCaptureFixture ,
573
+ ) -> None :
574
+ html = (
575
+ b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
576
+ b'<a href="/pkg1-1.0.tar.gz"></a><a href="/pkg1-2.0.tar.gz"></a>'
577
+ )
578
+ url = "https://example.com/simple/"
579
+ page = HTMLPage (html , encoding = None , url = url , cache_link_parsing = False )
580
+
581
+ with caplog .at_level (logging .WARN ):
582
+ parsed_links = list (parse_links (page , use_deprecated_html5lib = False ))
583
+
584
+ assert len (parsed_links ) == 2 , parsed_links
585
+ assert "pkg1-1.0" in parsed_links [0 ].url
586
+ assert "pkg1-2.0" in parsed_links [1 ].url
587
+
588
+ assert len (caplog .records ) == 1
569
589
570
590
571
591
@mock .patch ("pip._internal.index.collector.raise_for_status" )
0 commit comments