Skip to content

Commit

Permalink
Fix tests for Docutils revision 9928 (#12897)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 18, 2024
1 parent 56716ed commit 71b1a06
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions tests/test_builders/test_build_html_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,36 @@ def test_html_scaled_image_link(app):
assert re.search('\n<img alt="_images/img.png" src="_images/img.png" />', context)

# scaled_image_link
# Docutils 0.21 adds a newline before the closing </a> tag
closing_space = '\n' if docutils.__version_info__[:2] >= (0, 21) else ''
assert re.search(
'\n<a class="reference internal image-reference" href="_images/img.png">'
'<img alt="_images/img.png" src="_images/img.png" style="[^"]+" />'
f'{closing_space}</a>',
context,
)
if docutils.__version_info__[:2] >= (0, 22):
assert re.search(
'\n<a class="reference internal image-reference" href="_images/img.png">'
'<img alt="_images/img.png" height="[^"]+" src="_images/img.png" width="[^"]+" />'
'\n</a>',
context,
)
else:
# Docutils 0.21 adds a newline before the closing </a> tag
closing_space = '\n' if docutils.__version_info__[:2] >= (0, 21) else ''
assert re.search(
'\n<a class="reference internal image-reference" href="_images/img.png">'
'<img alt="_images/img.png" src="_images/img.png" style="[^"]+" />'
f'{closing_space}</a>',
context,
)

# no-scaled-link class disables the feature
assert re.search(
'\n<img alt="_images/img.png" class="no-scaled-link"'
' src="_images/img.png" style="[^"]+" />',
context,
)
if docutils.__version_info__[:2] >= (0, 22):
assert re.search(
'\n<img alt="_images/img.png" class="no-scaled-link"'
' height="[^"]+" src="_images/img.png" width="[^"]+" />',
context,
)
else:
assert re.search(
'\n<img alt="_images/img.png" class="no-scaled-link"'
' src="_images/img.png" style="[^"]+" />',
context,
)


@pytest.mark.usefixtures('_http_teapot')
Expand Down

0 comments on commit 71b1a06

Please sign in to comment.