You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/nbconvert/exporters/tests/test_asciidoc.py

70 lines
2.2 KiB

"""Tests for ASCIIDocExporter`"""
#-----------------------------------------------------------------------------
# Copyright (c) 2016, 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
#-----------------------------------------------------------------------------
import re
from traitlets.config import Config
from .base import ExportersTestsBase
from ..asciidoc import ASCIIDocExporter
from ...tests.utils import onlyif_cmds_exist
#-----------------------------------------------------------------------------
# Class
#-----------------------------------------------------------------------------
in_regex = r"In\[(.*)\]:"
out_regex = r"Out\[(.*)\]:"
class TestASCIIDocExporter(ExportersTestsBase):
"""Tests for ASCIIDocExporter"""
exporter_class = ASCIIDocExporter
def test_constructor(self):
"""
Can a ASCIIDocExporter be constructed?
"""
ASCIIDocExporter()
@onlyif_cmds_exist('pandoc')
def test_export(self):
"""
Can a ASCIIDocExporter export something?
"""
(output, resources) = ASCIIDocExporter().from_filename(self._get_notebook())
assert len(output) > 0
assert re.findall(in_regex, output)
assert re.findall(out_regex, output)
@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)