From b6eeb6f5a44df8d20f8ae1a05857fc8099067372 2014-10-15 20:12:10 From: Jessica B. Hamrick Date: 2014-10-15 20:12:10 Subject: [PATCH] Add regression tests for html nbconvert --- diff --git a/IPython/nbconvert/exporters/tests/files/notebook2.ipynb b/IPython/nbconvert/exporters/tests/files/notebook2.ipynb index a7fe1a5..69440fc 100644 --- a/IPython/nbconvert/exporters/tests/files/notebook2.ipynb +++ b/IPython/nbconvert/exporters/tests/files/notebook2.ipynb @@ -169,6 +169,15 @@ "language": "python", "metadata": {}, "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": null } ], "metadata": {} diff --git a/IPython/nbconvert/exporters/tests/test_html.py b/IPython/nbconvert/exporters/tests/test_html.py index ca4941a..decd081 100644 --- a/IPython/nbconvert/exporters/tests/test_html.py +++ b/IPython/nbconvert/exporters/tests/test_html.py @@ -15,6 +15,7 @@ from .base import ExportersTestsBase from ..html import HTMLExporter from IPython.testing.decorators import onlyif_any_cmd_exists +import re #----------------------------------------------------------------------------- # Class @@ -59,3 +60,17 @@ class TestHTMLExporter(ExportersTestsBase): (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook()) assert len(output) > 0 + @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') + def test_prompt_number(self): + """ + Does HTMLExporter properly format input and output prompts? + """ + (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook()) + in_regex = r"In \[(.*)\]:" + out_regex = r"Out\[(.*)\]:" + + ins = ["1", "2", "6", "7", "8", "10", "14", " ", " "] + outs = ["7", "10", "14"] + + assert re.findall(in_regex, output) == ins + assert re.findall(out_regex, output) == outs