2016-06-25 23:15:07 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_writer_latex
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the LaTeX writer
|
|
|
|
|
2017-03-22 06:21:12 -05:00
|
|
|
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
2016-06-25 23:15:07 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
from sphinx.writers.latex import rstdim_to_latexdim
|
|
|
|
|
2017-01-05 09:46:42 -06:00
|
|
|
import pytest
|
2016-06-25 23:31:07 -05:00
|
|
|
|
2016-06-25 23:15:07 -05:00
|
|
|
|
|
|
|
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'
|
2016-06-25 23:15:07 -05:00
|
|
|
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'
|
2016-06-25 23:56:19 -05:00
|
|
|
assert rstdim_to_latexdim('160') == '160\\sphinxpxdimen'
|
2016-06-25 23:15:07 -05:00
|
|
|
|
2016-06-25 23:44:48 -05:00
|
|
|
# flaot values
|
2016-06-25 23:15:07 -05:00
|
|
|
assert rstdim_to_latexdim('160.0em') == '160.0em'
|
2016-06-25 23:44:48 -05:00
|
|
|
assert rstdim_to_latexdim('.5em') == '.5em'
|
2016-06-25 23:31:07 -05:00
|
|
|
|
|
|
|
# unknown values (it might be generated by 3rd party extension)
|
2017-01-05 09:46:42 -06:00
|
|
|
with pytest.raises(ValueError):
|
|
|
|
rstdim_to_latexdim('unknown')
|
2016-06-25 23:31:07 -05:00
|
|
|
assert rstdim_to_latexdim('160.0unknown') == '160.0unknown'
|