Skip to content

Commit 98e845c

Browse files
committed
Add test
1 parent 05c0b6a commit 98e845c

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-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: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ 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(app,
59+
filename='projectnamenotset.tex',
60+
docclass='manual',
61+
runtwice=False):
5962
# now, try to run latex over it
6063
try:
6164
with chdir(app.outdir):
@@ -82,7 +85,7 @@ def compile_latex_document(app, filename='projectnamenotset.tex', docclass='manu
8285
# as configured in the Makefile and in presence of latexmkrc
8386
# or latexmkjarc and also sphinx.xdy and other xindy support.
8487
# And two passes are not enough except for simplest documents.
85-
if app.config.latex_engine == 'pdflatex':
88+
if runtwice:
8689
subprocess.run(args, capture_output=True, check=True)
8790
except OSError as exc: # most likely the latex executable was not found
8891
raise pytest.skip.Exception from exc
@@ -101,6 +104,10 @@ def compile_latex_document(app, filename='projectnamenotset.tex', docclass='manu
101104
not kpsetest(*STYLEFILES),
102105
reason='not running latex, the required styles do not seem to be installed',
103106
)
107+
skip_if_docutils_not_at_least_at_0_22 = pytest.mark.skipif(
108+
docutils.__version_info__[:2] < (0, 22),
109+
reason='this test requires Docutils at least at 0.22',
110+
)
104111

105112

106113
class RemoteImageHandler(http.server.BaseHTTPRequestHandler):
@@ -128,25 +135,29 @@ def do_GET(self):
128135
@skip_if_requested
129136
@skip_if_stylefiles_notfound
130137
@pytest.mark.parametrize(
131-
('engine', 'docclass', 'python_maximum_signature_line_length'),
138+
('engine', 'docclass', 'python_maximum_signature_line_length', 'runtwice'),
132139
# Only running test with `python_maximum_signature_line_length` not None with last
133140
# LaTeX engine to reduce testing time, as if this configuration does not fail with
134141
# one engine, it's almost impossible it would fail with another.
135142
[
136-
('pdflatex', 'manual', None),
137-
('pdflatex', 'howto', None),
138-
('lualatex', 'manual', None),
139-
('lualatex', 'howto', None),
140-
('xelatex', 'manual', 1),
141-
('xelatex', 'howto', 1),
143+
('pdflatex', 'manual', None, True),
144+
('pdflatex', 'howto', None, True),
145+
('lualatex', 'manual', None, False),
146+
('lualatex', 'howto', None, False),
147+
('xelatex', 'manual', 1, False),
148+
('xelatex', 'howto', 1, False),
142149
],
143150
)
144151
@pytest.mark.sphinx(
145152
'latex',
146153
testroot='root',
147154
freshenv=True,
148155
)
149-
def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_length):
156+
def test_build_latex_doc(app,
157+
engine,
158+
docclass,
159+
python_maximum_signature_line_length,
160+
runtwice):
150161
app.config.python_maximum_signature_line_length = (
151162
python_maximum_signature_line_length
152163
)
@@ -170,7 +181,25 @@ def test_build_latex_doc(app, engine, docclass, python_maximum_signature_line_le
170181
# file from latex_additional_files
171182
assert (app.outdir / 'svgimg.svg').is_file()
172183

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

175204

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

0 commit comments

Comments
 (0)