Merge branch '7.1.x'

# Conflicts:
#	CHANGES
#	sphinx/__init__.py
This commit is contained in:
Adam Turner 2023-08-02 02:58:30 +01:00
commit 43ab23a61f
3 changed files with 29 additions and 1 deletions

10
CHANGES
View File

@ -48,6 +48,16 @@ Bugs fixed
Testing
-------
Release 7.1.2 (released Aug 02, 2023)
=====================================
Bugs fixed
----------
* #11542: linkcheck: Properly respect :confval:`linkcheck_anchors`
and do not spuriously report failures to validate anchors.
Patch by James Addison.
Release 7.1.1 (released Jul 27, 2023)
=====================================

View File

@ -407,7 +407,8 @@ class HyperlinkAvailabilityCheckWorker(Thread):
_user_agent=self.user_agent,
_tls_info=(self.tls_verify, self.tls_cacerts),
) as response:
if response.ok and anchor and not contains_anchor(response, anchor):
if (self.check_anchors and response.ok and anchor
and not contains_anchor(response, anchor)):
raise Exception(__(f'Anchor {anchor!r} not found'))
# Copy data we need from the (closed) response

View File

@ -152,6 +152,7 @@ def test_defaults(app):
}
# looking for '#top' and '#does-not-exist' not found should fail
assert rowsby["http://localhost:7777/#top"]["info"] == "Anchor 'top' not found"
assert rowsby["http://localhost:7777/#top"]["status"] == "broken"
assert rowsby["http://localhost:7777#does-not-exist"]["info"] == "Anchor 'does-not-exist' not found"
# images should fail
assert "Not Found for url: http://localhost:7777/image.png" in rowsby["http://localhost:7777/image.png"]["info"]
@ -166,6 +167,22 @@ def test_defaults(app):
}
@pytest.mark.sphinx(
'linkcheck', testroot='linkcheck', freshenv=True,
confoverrides={'linkcheck_anchors': False})
def test_check_link_response_only(app):
with http_server(DefaultsHandler):
app.build()
# JSON output
assert (app.outdir / 'output.json').exists()
content = (app.outdir / 'output.json').read_text(encoding='utf8')
rows = [json.loads(x) for x in content.splitlines()]
rowsby = {row["uri"]: row for row in rows}
assert rowsby["http://localhost:7777/#top"]["status"] == "working"
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-too-many-retries', freshenv=True)
def test_too_many_retries(app):
with http_server(DefaultsHandler):