diff --git a/nbconvert/exporters/tests/test_asciidoc.py b/nbconvert/exporters/tests/test_asciidoc.py index be08077b4..9fb20be47 100644 --- a/nbconvert/exporters/tests/test_asciidoc.py +++ b/nbconvert/exporters/tests/test_asciidoc.py @@ -12,13 +12,19 @@ # Imports #----------------------------------------------------------------------------- +import re + +from traitlets.config import Config +from ipython_genutils.testing import decorators as dec + from .base import ExportersTestsBase from ..asciidoc import ASCIIDocExporter -from ipython_genutils.testing import decorators as dec #----------------------------------------------------------------------------- # Class #----------------------------------------------------------------------------- +in_regex = r"In\[(.*)\]:" +out_regex = r"Out\[(.*)\]:" class TestASCIIDocExporter(ExportersTestsBase): """Tests for ASCIIDocExporter""" @@ -39,3 +45,25 @@ def test_export(self): """ (output, resources) = ASCIIDocExporter().from_filename(self._get_notebook()) assert len(output) > 0 + + assert re.findall(in_regex, output) + assert re.findall(out_regex, output) + + @dec.onlyif_cmds_exist('pandoc') + def test_export_no_prompt(self): + """ + Can a ASCIIDocExporter export something without prompts? + """ + no_prompt = { + "TemplateExporter":{ + "exclude_input_prompt": True, + "exclude_output_prompt": True, + } + } + c_no_prompt = Config(no_prompt) + exporter = ASCIIDocExporter(config=c_no_prompt) + (output, resources) = exporter.from_filename( + self._get_notebook(nb_name="prompt_numbers.ipynb")) + + assert not re.findall(in_regex, output) + assert not re.findall(out_regex, output) diff --git a/nbconvert/exporters/tests/test_html.py b/nbconvert/exporters/tests/test_html.py index c7d5b20a5..1a771e023 100644 --- a/nbconvert/exporters/tests/test_html.py +++ b/nbconvert/exporters/tests/test_html.py @@ -3,10 +3,13 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +import re + from .base import ExportersTestsBase from ..html import HTMLExporter + +from traitlets.config import Config from nbformat import v4 -import re class TestHTMLExporter(ExportersTestsBase): @@ -59,6 +62,26 @@ def test_prompt_number(self): assert re.findall(in_regex, output) == ins assert re.findall(out_regex, output) == outs + + def test_prompt_number(self): + """ + Does HTMLExporter properly format input and output prompts? + """ + no_prompt_conf = Config( + {"TemplateExporter":{ + "exclude_input_prompt": True, + "exclude_output_prompt": True, + } + } + ) + exporter = HTMLExporter(config=no_prompt_conf, template_file='full') + (output, resources) = exporter.from_filename( + self._get_notebook(nb_name="prompt_numbers.ipynb")) + in_regex = r"In \[(.*)\]:" + out_regex = r"Out\[(.*)\]:" + + assert not re.findall(in_regex, output) + assert not re.findall(out_regex, output) def test_png_metadata(self): """ diff --git a/nbconvert/exporters/tests/test_latex.py b/nbconvert/exporters/tests/test_latex.py index 17a33851c..b58273293 100644 --- a/nbconvert/exporters/tests/test_latex.py +++ b/nbconvert/exporters/tests/test_latex.py @@ -9,6 +9,8 @@ from .base import ExportersTestsBase from ..latex import LatexExporter + +from traitlets.config import Config from nbformat import write from nbformat import v4 from ipython_genutils.testing.decorators import onlyif_cmds_exist @@ -117,6 +119,22 @@ def test_prompt_number_color(self): assert re.findall(in_regex, output) == ins assert re.findall(out_regex, output) == outs + @onlyif_cmds_exist('pandoc') + def test_no_prompt_yes_input(self): + no_prompt = { + "TemplateExporter":{ + "exclude_input_prompt": True, + "exclude_output_prompt": True, + } + } + c_no_prompt = Config(no_prompt) + + exporter = LatexExporter(config=c_no_prompt) + (output, resources) = exporter.from_filename( + self._get_notebook(nb_name="prompt_numbers.ipynb")) + assert "shape" in output + assert "evs" in output + def test_in_memory_template_tplx(self): # Loads in an in memory latex template (.tplx) using jinja2.DictLoader # creates a class that uses this template with the template_file argument diff --git a/nbconvert/templates/html/basic.tpl b/nbconvert/templates/html/basic.tpl index eaec1f701..9159415ab 100644 --- a/nbconvert/templates/html/basic.tpl +++ b/nbconvert/templates/html/basic.tpl @@ -23,21 +23,17 @@ {% block in_prompt -%}