summaryrefslogtreecommitdiffstats
path: root/tests/test_writers/test_writer_latex.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:20:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:20:58 +0000
commit5bb0bb4be543fd5eca41673696a62ed80d493591 (patch)
treead2c464f140e86c7f178a6276d7ea4a93e3e6c92 /tests/test_writers/test_writer_latex.py
parentAdding upstream version 7.2.6. (diff)
downloadsphinx-upstream/7.3.7.tar.xz
sphinx-upstream/7.3.7.zip
Adding upstream version 7.3.7.upstream/7.3.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_writers/test_writer_latex.py')
-rw-r--r--tests/test_writers/test_writer_latex.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_writers/test_writer_latex.py b/tests/test_writers/test_writer_latex.py
new file mode 100644
index 0000000..a0ab3ee
--- /dev/null
+++ b/tests/test_writers/test_writer_latex.py
@@ -0,0 +1,28 @@
+"""Test the LaTeX writer"""
+
+import pytest
+
+from sphinx.writers.latex import rstdim_to_latexdim
+
+
+def test_rstdim_to_latexdim():
+ # Length units docutils supported
+ # https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#length-units
+ assert rstdim_to_latexdim('160em') == '160em'
+ assert rstdim_to_latexdim('160px') == '160\\sphinxpxdimen'
+ assert rstdim_to_latexdim('160in') == '160in'
+ assert rstdim_to_latexdim('160cm') == '160cm'
+ assert rstdim_to_latexdim('160mm') == '160mm'
+ assert rstdim_to_latexdim('160pt') == '160bp'
+ assert rstdim_to_latexdim('160pc') == '160pc'
+ assert rstdim_to_latexdim('30%') == '0.300\\linewidth'
+ assert rstdim_to_latexdim('160') == '160\\sphinxpxdimen'
+
+ # float values
+ assert rstdim_to_latexdim('160.0em') == '160.0em'
+ assert rstdim_to_latexdim('.5em') == '.5em'
+
+ # unknown values (it might be generated by 3rd party extension)
+ with pytest.raises(ValueError, match='could not convert string to float: '):
+ rstdim_to_latexdim('unknown')
+ assert rstdim_to_latexdim('160.0unknown') == '160.0unknown'