sphinx/tests/test_writer_latex.py

37 lines
1.2 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
test_writer_latex
~~~~~~~~~~~~~~~~
Test the LaTeX writer
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
from sphinx.writers.latex import rstdim_to_latexdim
from util import raises
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'
2016-06-25 23:44:48 -05:00
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') is None
2016-06-25 23:44:48 -05:00
# flaot values
assert rstdim_to_latexdim('160.0em') == '160.0em'
2016-06-25 23:44:48 -05:00
assert rstdim_to_latexdim('.5em') == '.5em'
# unknown values (it might be generated by 3rd party extension)
raises(ValueError, rstdim_to_latexdim, 'unknown')
assert rstdim_to_latexdim('160.0unknown') == '160.0unknown'