Files
sphinx/tests/test_writer_latex.py
T
Jon Dufresne bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00

37 lines
1.2 KiB
Python

"""
test_writer_latex
~~~~~~~~~~~~~~~~
Test the LaTeX writer
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import pytest
from sphinx.writers.latex import rstdim_to_latexdim
def test_rstdim_to_latexdim():
# Length units docutils supported
# http://docutils.sourceforge.net/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):
rstdim_to_latexdim('unknown')
assert rstdim_to_latexdim('160.0unknown') == '160.0unknown'