Skip to content

Commit 1a48593

Browse files
drammockjarrodmillman
authored andcommitted
keep test_reference backwards-compatible
1 parent 071c71e commit 1a48593

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

numpydoc/tests/test_full.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import os.path as op
22
import re
33
import shutil
4+
from packaging import version
45

56
import pytest
67
import sphinx
78
from sphinx.application import Sphinx
89
from sphinx.util.docutils import docutils_namespace
10+
from docutils import __version__ as docutils_version
911

1012

1113
# Test framework adapted from sphinx-gallery (BSD 3-clause)
@@ -89,7 +91,12 @@ def test_reference(sphinx_app, html_file, expected_length):
8991
with open(op.join(out_dir, *html_file)) as fid:
9092
html = fid.read()
9193

92-
reference_list = re.findall(r'<a role="doc-backlink" href="\#id\d+">(.*)<\/a>', html)
94+
pattern = (
95+
'role="doc-backlink"'
96+
if version.parse(docutils_version) >= version.parse("0.18")
97+
else 'class="fn-backref"'
98+
)
99+
reference_list = re.findall(rf'<a {pattern} href="\#id\d+">(.*)<\/a>', html)
93100

94101
assert len(reference_list) == expected_length
95102
for ref in reference_list:

0 commit comments

Comments
 (0)