diff --git a/tests/roots/test-linkcheck-connection-error-on-http-head/conf.py b/tests/roots/test-linkcheck-connection-error-on-http-head/conf.py new file mode 100644 index 000000000..a45d22e28 --- /dev/null +++ b/tests/roots/test-linkcheck-connection-error-on-http-head/conf.py @@ -0,0 +1 @@ +exclude_patterns = ['_build'] diff --git a/tests/roots/test-linkcheck-connection-error-on-http-head/index.rst b/tests/roots/test-linkcheck-connection-error-on-http-head/index.rst new file mode 100644 index 000000000..bdb5fecb2 --- /dev/null +++ b/tests/roots/test-linkcheck-connection-error-on-http-head/index.rst @@ -0,0 +1 @@ +This is `a link to the US Patent Website `_ diff --git a/tests/test_build_linkcheck.py b/tests/test_build_linkcheck.py index fd7a5482a..810d5555e 100644 --- a/tests/test_build_linkcheck.py +++ b/tests/test_build_linkcheck.py @@ -575,3 +575,20 @@ def test_limit_rate_bails_out_after_waiting_max_time(app): rate_limits) next_check = worker.limit_rate(FakeResponse()) assert next_check is None + + +@pytest.mark.sphinx('linkcheck', testroot='linkcheck-connection-error-on-http-head', freshenv=True) +def test_get_after_head_raises_connection_error(app): + class InternalServerErrorHandler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + self.send_error(500, "Internal Server Error") + + with http_server(InternalServerErrorHandler): + app.build() + content = (app.outdir / 'output.txt').read_text() + assert "broken" not in content + # assert content == ( + # "index.rst:1: [broken] http://localhost:7777/#anchor: " + # "500 Server Error: Internal Server Error " + # "for url: http://localhost:7777/\n" + # )