Show More
@@ -0,0 +1,43 b'' | |||||
|
1 | """ | |||
|
2 | Module with tests for the latex transformer | |||
|
3 | """ | |||
|
4 | ||||
|
5 | #----------------------------------------------------------------------------- | |||
|
6 | # Copyright (c) 2013, the IPython Development Team. | |||
|
7 | # | |||
|
8 | # 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 | ||||
|
13 | #----------------------------------------------------------------------------- | |||
|
14 | # Imports | |||
|
15 | #----------------------------------------------------------------------------- | |||
|
16 | ||||
|
17 | from .base import TransformerTestsBase | |||
|
18 | from ..latex import LatexTransformer | |||
|
19 | ||||
|
20 | ||||
|
21 | #----------------------------------------------------------------------------- | |||
|
22 | # Class | |||
|
23 | #----------------------------------------------------------------------------- | |||
|
24 | ||||
|
25 | class TestLatex(TransformerTestsBase): | |||
|
26 | """Contains test functions for latex.py""" | |||
|
27 | ||||
|
28 | def test_constructor(self): | |||
|
29 | """Can a LatexTransformer be constructed?""" | |||
|
30 | transformer = LatexTransformer() | |||
|
31 | transformer.enabled = True | |||
|
32 | return transformer | |||
|
33 | ||||
|
34 | ||||
|
35 | def test_output(self): | |||
|
36 | """Test the output of the LatexTransformer""" | |||
|
37 | nb, res = self.test_constructor()(self.build_notebook(), {}) | |||
|
38 | ||||
|
39 | # Make sure the code cell wasn't modified. | |||
|
40 | self.assertEqual(nb.worksheets[0].cells[0].input, '$ e $') | |||
|
41 | ||||
|
42 | # Verify that the markdown cell was processed. | |||
|
43 | self.assertEqual(nb.worksheets[0].cells[1].source, '$e$') |
@@ -1,44 +1,44 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Module with utility functions for transformer tests |
|
2 | Module with utility functions for transformer tests | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
5 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
6 | # Copyright (c) 2013, the IPython Development Team. |
|
6 | # Copyright (c) 2013, the IPython Development Team. | |
7 | # |
|
7 | # | |
8 | # Distributed under the terms of the Modified BSD License. |
|
8 | # Distributed under the terms of the Modified BSD License. | |
9 | # |
|
9 | # | |
10 | # The full license is in the file COPYING.txt, distributed with this software. |
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 |
|
12 | |||
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 |
|
16 | |||
17 | from ...tests.base import TestsBase |
|
17 | from ...tests.base import TestsBase | |
18 |
|
18 | |||
19 | from IPython.nbformat import current as nbformat |
|
19 | from IPython.nbformat import current as nbformat | |
20 |
|
20 | |||
21 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
22 | # Class |
|
22 | # Class | |
23 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
24 |
|
24 | |||
25 | class TransformerTestsBase(TestsBase): |
|
25 | class TransformerTestsBase(TestsBase): | |
26 | """Contains test functions transformer tests""" |
|
26 | """Contains test functions transformer tests""" | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | def build_notebook(self): |
|
29 | def build_notebook(self): | |
30 | """Build a notebook in memory for use with transformer tests""" |
|
30 | """Build a notebook in memory for use with transformer tests""" | |
31 |
|
31 | |||
32 | outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="a"), |
|
32 | outputs = [nbformat.new_output(output_type="stream", stream="stdout", output_text="a"), | |
33 | nbformat.new_output(output_type="text", output_text="b"), |
|
33 | nbformat.new_output(output_type="text", output_text="b"), | |
34 | nbformat.new_output(output_type="stream", stream="stdout", output_text="c"), |
|
34 | nbformat.new_output(output_type="stream", stream="stdout", output_text="c"), | |
35 | nbformat.new_output(output_type="stream", stream="stdout", output_text="d"), |
|
35 | nbformat.new_output(output_type="stream", stream="stdout", output_text="d"), | |
36 | nbformat.new_output(output_type="stream", stream="stderr", output_text="e"), |
|
36 | nbformat.new_output(output_type="stream", stream="stderr", output_text="e"), | |
37 | nbformat.new_output(output_type="stream", stream="stderr", output_text="f"), |
|
37 | nbformat.new_output(output_type="stream", stream="stderr", output_text="f"), | |
38 | nbformat.new_output(output_type="png", output_png='Zw==')] #g |
|
38 | nbformat.new_output(output_type="png", output_png='Zw==')] #g | |
39 |
|
39 | |||
40 |
cells=[nbformat.new_code_cell(input=" |
|
40 | cells=[nbformat.new_code_cell(input="$ e $", prompt_number=1,outputs=outputs), | |
41 | prompt_number=1,outputs=outputs)] |
|
41 | nbformat.new_text_cell('markdown', source="$ e $")] | |
42 | worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] |
|
42 | worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] | |
43 |
|
43 | |||
44 | return nbformat.new_notebook(name="notebook1", worksheets=worksheets) |
|
44 | return nbformat.new_notebook(name="notebook1", worksheets=worksheets) |
General Comments 0
You need to be logged in to leave comments.
Login now