##// END OF EJS Templates
Rework Latex test for nbconvert Python API...
Thomas Kluyver -
Show More
@@ -1,26 +1,17 b''
1 """
2 Module with tests for latex.py
3 """
1 """Tests for Latex exporter"""
4 2
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
7 #
3 # Copyright (c) IPython Development Team.
8 4 # Distributed under the terms of the Modified BSD License.
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
12 5
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
6 import os.path
7 import textwrap
16 8
17 9 from .base import ExportersTestsBase
18 10 from ..latex import LatexExporter
11 from IPython.nbformat import current
19 12 from IPython.testing.decorators import onlyif_cmds_exist
13 from IPython.utils.tempdir import TemporaryDirectory
20 14
21 #-----------------------------------------------------------------------------
22 # Class
23 #-----------------------------------------------------------------------------
24 15
25 16 class TestLatexExporter(ExportersTestsBase):
26 17 """Contains test functions for latex.py"""
@@ -68,4 +59,43 b' class TestLatexExporter(ExportersTestsBase):'
68 59 Can a LatexExporter export using 'article' template?
69 60 """
70 61 (output, resources) = LatexExporter(template_file='article').from_filename(self._get_notebook())
71 assert len(output) > 0 No newline at end of file
62 assert len(output) > 0
63
64 @onlyif_cmds_exist('pandoc')
65 def test_very_long_cells(self):
66 """
67 Torture test that long cells do not cause issues
68 """
69 lorem_ipsum_text = textwrap.dedent("""\
70 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
71 dignissim, ipsum non facilisis tempus, dui felis tincidunt metus,
72 nec pulvinar neque odio eget risus. Nulla nisi lectus, cursus
73 suscipit interdum at, ultrices sit amet orci. Mauris facilisis
74 imperdiet elit, vitae scelerisque ipsum dignissim non. Integer
75 consequat malesuada neque sit amet pulvinar. Curabitur pretium
76 ut turpis eget aliquet. Maecenas sagittis lacus sed lectus
77 volutpat, eu adipiscing purus pulvinar. Maecenas consequat
78 luctus urna, eget cursus quam mollis a. Aliquam vitae ornare
79 erat, non hendrerit urna. Sed eu diam nec massa egestas pharetra
80 at nec tellus. Fusce feugiat lacus quis urna sollicitudin volutpat.
81 Quisque at sapien non nibh feugiat tempus ac ultricies purus.
82 """)
83 lorem_ipsum_text = lorem_ipsum_text.replace("\n"," ") + "\n\n"
84 large_lorem_ipsum_text = "".join([lorem_ipsum_text]*3000)
85
86 notebook_name = "lorem_ipsum_long.ipynb"
87 nb = current.new_notebook(
88 worksheets=[
89 current.new_worksheet(cells=[
90 current.new_text_cell('markdown',source=large_lorem_ipsum_text)
91 ])
92 ]
93 )
94
95 with TemporaryDirectory() as td:
96 nbfile = os.path.join(td, notebook_name)
97 with open(nbfile, 'w') as f:
98 current.write(nb, f, 'ipynb')
99
100 (output, resources) = LatexExporter(template_file='article').from_filename(nbfile)
101 assert len(output) > 0
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now