test_connect_to_selfsigned_fails can time out before certificate verification
Describe the bug
Hej,
I found this while reviewing the CI failures for #14681.
The Windows job intermittently failed in tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_fails because the HTTPS request reached its 0.25-second read timeout before certificate verification completed.
The test expects the self-signed certificate to produce:
status: broken
info: ... [SSL: CERTIFICATE_VERIFY_FAILED] ...Instead, linkcheck can report:
status: timeout
info: ... Read timed out. (read timeout=0.25)This is a test-infrastructure timing failure.
How to Reproduce
The failure is intermittent. On Windows, repeatedly run:
1..200 | ForEach-Object {
Write-Host "Attempt $_"
uv run pytest -q `
tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_fails
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}It may be easier to reproduce under the load and scheduling of the complete test suite:
uv run pytest -vv --durations 25An example occurred in this Windows CI job: https://github.com/sphinx-doc/sphinx/actions/runs/35436525563/job/105880014681
Environment Information
Platform: Windows
Python version: 3.14.7
Sphinx version: 9.1.1+/d85f0ae
Docutils version: 0.22.4
pytest version: 9.1.1Sphinx extensions
[]Additional context
The same test and failure mode were previously reported in #12038. That issue was closed after increasing the linkcheck test timeout and adding a server readiness check. Those changes reduced the frequency of the failure but did not eliminate it.
Source: sphinx-doc/sphinx