From 1642fb982c73e3b2496f46621b81ca4593a99290 2013-08-07 16:13:48 From: Jonathan Frederic Date: 2013-08-07 16:13:48 Subject: [PATCH] Added latex transformer test --- diff --git a/IPython/nbconvert/transformers/tests/base.py b/IPython/nbconvert/transformers/tests/base.py index 28d3891..f77d491 100644 --- a/IPython/nbconvert/transformers/tests/base.py +++ b/IPython/nbconvert/transformers/tests/base.py @@ -37,8 +37,8 @@ class TransformerTestsBase(TestsBase): nbformat.new_output(output_type="stream", stream="stderr", output_text="f"), nbformat.new_output(output_type="png", output_png='Zw==')] #g - cells=[nbformat.new_code_cell(input="test", - prompt_number=1,outputs=outputs)] + cells=[nbformat.new_code_cell(input="$ e $", prompt_number=1,outputs=outputs), + nbformat.new_text_cell('markdown', source="$ e $")] worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] return nbformat.new_notebook(name="notebook1", worksheets=worksheets) diff --git a/IPython/nbconvert/transformers/tests/test_latex.py b/IPython/nbconvert/transformers/tests/test_latex.py new file mode 100644 index 0000000..0c6a66c --- /dev/null +++ b/IPython/nbconvert/transformers/tests/test_latex.py @@ -0,0 +1,43 @@ +""" +Module with tests for the latex transformer +""" + +#----------------------------------------------------------------------------- +# Copyright (c) 2013, the IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +from .base import TransformerTestsBase +from ..latex import LatexTransformer + + +#----------------------------------------------------------------------------- +# Class +#----------------------------------------------------------------------------- + +class TestLatex(TransformerTestsBase): + """Contains test functions for latex.py""" + + def test_constructor(self): + """Can a LatexTransformer be constructed?""" + transformer = LatexTransformer() + transformer.enabled = True + return transformer + + + def test_output(self): + """Test the output of the LatexTransformer""" + nb, res = self.test_constructor()(self.build_notebook(), {}) + + # Make sure the code cell wasn't modified. + self.assertEqual(nb.worksheets[0].cells[0].input, '$ e $') + + # Verify that the markdown cell was processed. + self.assertEqual(nb.worksheets[0].cells[1].source, '$e$')