Skip to content

Commit

Permalink
Lint fixups: adjust to within ruff guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Aug 11, 2024
1 parent bbeb1e4 commit d8e7f33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions tests/test_builders/test_build_html_toctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ def test_numbered_toctree(app):
app.build(force_all=True)


@pytest.mark.parametrize("expect", [
# internal references should be same-document; external should not
(".//a[@class='reference internal']", _intradocument_hyperlink_check),
(".//a[@class='reference external']", r'https?://'),
])
@pytest.mark.parametrize(
'expect',
[
# internal references should be same-document; external should not
(".//a[@class='reference internal']", _intradocument_hyperlink_check),
(".//a[@class='reference external']", r'https?://'),
],
)
@pytest.mark.sphinx('singlehtml', testroot='toctree')
def test_singlehtml_hyperlinks(app, cached_etree_parse, expect):
app.build()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_builders/xpath_html_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

def _intradocument_hyperlink_check(nodes: Sequence[Element]) -> None:
"""Confirm that a series of nodes are all HTML hyperlinks to the current page"""
assert nodes, "Expected at least one node to check"
assert nodes, 'Expected at least one node to check'
for node in nodes:
assert node.tag == 'a', 'Same-document hyperlink check attempted on non-anchor element'
assert node.tag == 'a', 'Attempted to check hyperlink on a non-anchor element'
href = node.attrib.get('href')
# Allow Sphinx index and table hyperlinks to be non-same-document, as exceptions.
if href in {'genindex.html', 'py-modindex.html', 'search.html'}:
continue
assert (not href or href.startswith('#')), 'Hyperlink failed same-document check'
assert not href or href.startswith('#'), 'Hyperlink failed same-document check'

0 comments on commit d8e7f33

Please sign in to comment.