Show More
@@ -0,0 +1,64 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | """Test Latex in NbConvertApp""" | |||
|
3 | ||||
|
4 | #----------------------------------------------------------------------------- | |||
|
5 | # Copyright (C) 2013 The IPython Development Team | |||
|
6 | # | |||
|
7 | # Distributed under the terms of the BSD License. The full license is in | |||
|
8 | # the file COPYING, distributed as part of this software. | |||
|
9 | #----------------------------------------------------------------------------- | |||
|
10 | ||||
|
11 | #----------------------------------------------------------------------------- | |||
|
12 | # Imports | |||
|
13 | #----------------------------------------------------------------------------- | |||
|
14 | ||||
|
15 | import os | |||
|
16 | import textwrap | |||
|
17 | from IPython.nbformat import current | |||
|
18 | ||||
|
19 | from .base import TestsBase | |||
|
20 | ||||
|
21 | #----------------------------------------------------------------------------- | |||
|
22 | # Classes and functions | |||
|
23 | #----------------------------------------------------------------------------- | |||
|
24 | ||||
|
25 | class TestNbConvertLatex(TestsBase): | |||
|
26 | """Collection of NbConvert Latex tests""" | |||
|
27 | ||||
|
28 | def test_very_long_cells(self): | |||
|
29 | """ | |||
|
30 | Torture test that long cells do not cause issues | |||
|
31 | """ | |||
|
32 | lorem_ipsum_text = textwrap.dedent("""\ | |||
|
33 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec | |||
|
34 | dignissim, ipsum non facilisis tempus, dui felis tincidunt metus, | |||
|
35 | nec pulvinar neque odio eget risus. Nulla nisi lectus, cursus | |||
|
36 | suscipit interdum at, ultrices sit amet orci. Mauris facilisis | |||
|
37 | imperdiet elit, vitae scelerisque ipsum dignissim non. Integer | |||
|
38 | consequat malesuada neque sit amet pulvinar. Curabitur pretium | |||
|
39 | ut turpis eget aliquet. Maecenas sagittis lacus sed lectus | |||
|
40 | volutpat, eu adipiscing purus pulvinar. Maecenas consequat | |||
|
41 | luctus urna, eget cursus quam mollis a. Aliquam vitae ornare | |||
|
42 | erat, non hendrerit urna. Sed eu diam nec massa egestas pharetra | |||
|
43 | at nec tellus. Fusce feugiat lacus quis urna sollicitudin volutpat. | |||
|
44 | Quisque at sapien non nibh feugiat tempus ac ultricies purus. | |||
|
45 | """) | |||
|
46 | lorem_ipsum_text = lorem_ipsum_text.replace("\n"," ") + "\n\n" | |||
|
47 | large_lorem_ipsum_text = "".join([lorem_ipsum_text]*3000) | |||
|
48 | ||||
|
49 | notebook_name = "lorem_ipsum_long.ipynb" | |||
|
50 | tex_name = "lorem_ipsum_long.tex" | |||
|
51 | with self.create_temp_cwd([]): | |||
|
52 | nb = current.new_notebook( | |||
|
53 | worksheets=[ | |||
|
54 | current.new_worksheet(cells=[ | |||
|
55 | current.new_text_cell('markdown',source=large_lorem_ipsum_text) | |||
|
56 | ]) | |||
|
57 | ] | |||
|
58 | ) | |||
|
59 | with open(notebook_name, 'w') as f: current.write(nb, f, 'ipynb') | |||
|
60 | self.call('nbconvert --to latex --log-level 0 ' + | |||
|
61 | os.path.join(notebook_name)) | |||
|
62 | assert os.path.isfile(tex_name) | |||
|
63 | ||||
|
64 |
General Comments 0
You need to be logged in to leave comments.
Login now