Skip to content

Commit 561f5c2

Browse files
committed
Test that do not fail when running LaTeX builder with hoverxref_auto_ref=True
1 parent 4569657 commit 561f5c2

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/examples/default/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ Using ``hoverxref`` (or ``ref`` if ``hoverxref_auto_ref=True``) should add an ``
99
:ref:`This a :ref: to Chapter I <Chapter I>`.
1010

1111
:hoverxref:`This a :hoverxref: to Chapter I, Section I <Section I>`.
12+
13+
.. _example-reference:
14+
15+
Example Reference
16+
-----------------
17+
18+
This is a reference to :ref:`example-reference`.

tests/test_internals.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,33 @@ def test_override_translator_non_html_builder(app, status, warning):
4444
assert app.builder.format == 'html'
4545
for name, klass in app.registry.translators.items():
4646
assert issubclass(klass, HoverXRefHTMLTranslatorMixin)
47+
48+
49+
@pytest.mark.sphinx(
50+
srcdir=srcdir,
51+
buildername='latex',
52+
confoverrides={
53+
'hoverxref_project': 'myproject',
54+
'hoverxref_version': 'myversion',
55+
'hoverxref_auto_ref': True,
56+
},
57+
)
58+
def test_dont_fail_non_html_builder(app, status, warning):
59+
"""
60+
Test our resolver is not used by non-HTML builder.
61+
62+
When running the build with ``latex`` as builder and
63+
``hoverxref_auto_ref=True`` it should not fail with
64+
65+
def _get_docpath(self, builder, docname):
66+
docpath = builder.get_outfilename(docname)
67+
AttributeError: 'LaTeXBuilder' object has no attribute 'get_outfilename'
68+
69+
LaTeXBuilder should never use our resolver.
70+
"""
71+
app.build()
72+
path = app.outdir / 'test.tex'
73+
assert path.exists() is True
74+
content = open(path).read()
75+
76+
assert app.builder.format == 'latex'

0 commit comments

Comments
 (0)