Show More
@@ -1,42 +1,65 b'' | |||||
1 | """Tests for RSTExporter""" |
|
1 | """Tests for RSTExporter""" | |
2 |
|
2 | |||
3 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
4 | # Copyright (c) 2013, the IPython Development Team. |
|
4 | # Copyright (c) 2013, the IPython Development Team. | |
5 | # |
|
5 | # | |
6 | # Distributed under the terms of the Modified BSD License. |
|
6 | # Distributed under the terms of the Modified BSD License. | |
7 | # |
|
7 | # | |
8 | # The full license is in the file COPYING.txt, distributed with this software. |
|
8 | # The full license is in the file COPYING.txt, distributed with this software. | |
9 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
10 |
|
10 | |||
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 | # Imports |
|
12 | # Imports | |
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 |
|
14 | |||
|
15 | import io | |||
|
16 | ||||
|
17 | from IPython.nbformat import current | |||
|
18 | ||||
15 | from .base import ExportersTestsBase |
|
19 | from .base import ExportersTestsBase | |
16 | from ..rst import RSTExporter |
|
20 | from ..rst import RSTExporter | |
17 | from IPython.testing.decorators import onlyif_cmds_exist |
|
21 | from IPython.testing.decorators import onlyif_cmds_exist | |
18 |
|
22 | |||
19 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
20 | # Class |
|
24 | # Class | |
21 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
22 |
|
26 | |||
23 | class TestRSTExporter(ExportersTestsBase): |
|
27 | class TestRSTExporter(ExportersTestsBase): | |
24 | """Tests for RSTExporter""" |
|
28 | """Tests for RSTExporter""" | |
25 |
|
29 | |||
26 | exporter_class = RSTExporter |
|
30 | exporter_class = RSTExporter | |
27 | should_include_raw = ['rst'] |
|
31 | should_include_raw = ['rst'] | |
28 |
|
32 | |||
29 | def test_constructor(self): |
|
33 | def test_constructor(self): | |
30 | """ |
|
34 | """ | |
31 | Can a RSTExporter be constructed? |
|
35 | Can a RSTExporter be constructed? | |
32 | """ |
|
36 | """ | |
33 | RSTExporter() |
|
37 | RSTExporter() | |
34 |
|
38 | |||
35 |
|
39 | |||
36 | @onlyif_cmds_exist('pandoc') |
|
40 | @onlyif_cmds_exist('pandoc') | |
37 | def test_export(self): |
|
41 | def test_export(self): | |
38 | """ |
|
42 | """ | |
39 | Can a RSTExporter export something? |
|
43 | Can a RSTExporter export something? | |
40 | """ |
|
44 | """ | |
41 | (output, resources) = RSTExporter().from_filename(self._get_notebook()) |
|
45 | (output, resources) = RSTExporter().from_filename(self._get_notebook()) | |
42 | assert len(output) > 0 |
|
46 | assert len(output) > 0 | |
|
47 | ||||
|
48 | @onlyif_cmds_exist('pandoc') | |||
|
49 | def test_empty_code_cell(self): | |||
|
50 | """No empty code cells in rst""" | |||
|
51 | nbname = self._get_notebook() | |||
|
52 | with io.open(nbname, encoding='utf8') as f: | |||
|
53 | nb = current.read(f, 'json') | |||
|
54 | ||||
|
55 | exporter = self.exporter_class() | |||
|
56 | ||||
|
57 | (output, resources) = exporter.from_notebook_node(nb) | |||
|
58 | # add an empty code cell | |||
|
59 | nb.worksheets[0].cells.append( | |||
|
60 | current.new_code_cell(input="") | |||
|
61 | ) | |||
|
62 | (output2, resources) = exporter.from_notebook_node(nb) | |||
|
63 | # adding an empty code cell shouldn't change output | |||
|
64 | self.assertEqual(output.strip(), output2.strip()) | |||
|
65 |
General Comments 0
You need to be logged in to leave comments.
Login now