Skip to content

Commit 88ba474

Browse files
committed
Add test
1 parent 05c0b6a commit 88ba474

File tree

4 files changed

+60
-11
lines changed

4 files changed

+60
-11
lines changed

tests/roots/test-latex-images-css3-lengths/conf.py

Whitespace-only changes.
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=============
2+
TEST IMAGES
3+
=============
4+
5+
test-latex-images-css3-lengths
6+
==============================
7+
8+
.. image:: img.png
9+
:width: 10.03ch
10+
:height: 9.97rem
11+
12+
.. image:: img.png
13+
:width: 60vw
14+
:height: 10vh
15+
16+
.. image:: img.png
17+
:width: 10.5vmin
18+
:height: 10.5vmax
19+
20+
.. image:: img.png
21+
:width: 195.345Q
22+
23+
.. image:: img.png
24+
:width: 195.345Q
25+
:scale: 50%

tests/test_builders/test_build_latex.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def kpsetest(*filenames):
5555

5656

5757
# compile latex document with app.config.latex_engine
58-
def compile_latex_document(app, filename='projectnamenotset.tex', docclass='manual'):
58+
def compile_latex_document(
59+
app, filename='projectnamenotset.tex', docclass='manual', runtwice=False
60+
):
5961
# now, try to run latex over it
6062
try:
6163
with chdir(app.outdir):
@@ -82,7 +84,7 @@ def compile_latex_document(app, filename='projectnamenotset.tex', docclass='manu
8284
# as configured in the Makefile and in presence of latexmkrc
8385
# or latexmkjarc and also sphinx.xdy and other xindy support.
8486
# And two passes are not enough except for simplest documents.
85-
if app.config.latex_engine == 'pdflatex':
87+
if runtwice:
8688
subprocess.run(args, capture_output=True, check=True)
8789
except OSError as exc: # most likely the latex executable was not found
8890
raise pytest.skip.Exception from exc
@@ -101,6 +103,10 @@ def compile_latex_document(app, filename='projectnamenotset.tex', docclass='manu
101103
not kpsetest(*STYLEFILES),
102104
reason='not running latex, the required styles do not seem to be installed',
103105
)
106+
skip_if_docutils_not_at_least_at_0_22 = pytest.mark.skipif(
107+
docutils.__version_info__[:2] < (0, 22),
108+
reason='this test requires Docutils at least at 0.22',
109+
)
104110

105111

106112
class RemoteImageHandler(http.server.BaseHTTPRequestHandler):
@@ -128,25 +134,27 @@ def do_GET(self):
128134
@skip_if_requested
129135
@skip_if_stylefiles_notfound
130136
@pytest.mark.parametrize(
131-
('engine', 'docclass', 'python_maximum_signature_line_length'),
137+
('engine', 'docclass', 'python_maximum_signature_line_length', 'runtwice'),
132138
# Only running test with `python_maximum_signature_line_length` not None with last
133139
# LaTeX engine to reduce testing time, as if this configuration does not fail with
134140
# one engine, it's almost impossible it would fail with another.
135141
[
136-
('pdflatex', 'manual', None),
137-
('pdflatex', 'howto', None),
138-
('lualatex', 'manual', None),
139-
('lualatex', 'howto', None),
140-
('xelatex', 'manual', 1),
141-
('xelatex', 'howto', 1),
142+
('pdflatex', 'manual', None, True),
143+
('pdflatex', 'howto', None, True),
144+
('lualatex', 'manual', None, False),
145+
('lualatex', 'howto', None, False),
146+
('xelatex', 'manual', 1, False),
147+
('xelatex', 'howto', 1, False),
142148
],
143149
)
144150
@pytest.mark.sphinx(
145151
'latex',
146152
testroot='root',
147153
freshenv=True,
148154
)
149-
def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_length):
155+
def test_build_latex_doc(
156+
app, engine, docclass, python_maximum_signature_line_length, runtwice
157+
):
150158
app.config.python_maximum_signature_line_length = (
151159
python_maximum_signature_line_length
152160
)
@@ -170,7 +178,23 @@ def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_le
170178
# file from latex_additional_files
171179
assert (app.outdir / 'svgimg.svg').is_file()
172180

173-
compile_latex_document(app, 'sphinxtests.tex', docclass)
181+
compile_latex_document(app, 'sphinxtests.tex', docclass, runtwice)
182+
183+
184+
@skip_if_requested
185+
@skip_if_stylefiles_notfound
186+
@skip_if_docutils_not_at_least_at_0_22
187+
@pytest.mark.parametrize('engine', ['pdflatex', 'lualatex', 'xelatex'])
188+
@pytest.mark.sphinx(
189+
'latex',
190+
testroot='latex-images-css3-lengths',
191+
)
192+
def test_build_latex_with_css3_lengths(app, engine):
193+
app.config.latex_engine = engine
194+
app.config.latex_documents = [(*app.config.latex_documents[0][:4], 'howto')]
195+
app.builder.init()
196+
app.build(force_all=True)
197+
compile_latex_document(app, docclass='howto')
174198

175199

176200
@pytest.mark.sphinx('latex', testroot='root')

0 commit comments

Comments
 (0)