##// END OF EJS Templates
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook....
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook. Here's a brief overview of the changes: - Display of messages from other clients can be toggled on and off from within a notebook, either using the ``<M-m>e`` keyboard shortcut in the web UI, or through the option in the "Kernel" menu. - notebook.js controls whether messages are displayed through a callback that is invoked from kernel.js when no callbacks are available for a message. - The UI displays ``execute_input`` messages originating from an other clients in new cells at the end of the notebook. Output messages (``execute_result`` et al.) will only be displayed if a cell exists with a matching message ID. Pending design questions: - Should each ``execute_input`` message cause a new cell to be created? - Should new cells be placed at the end of the notebook, or elsewhere? If the latter, what criteria should be followed?

File last commit:

r18613:380a2e94
r19164:17ac8ca3
Show More
test_latex.py
117 lines | 4.0 KiB | text/x-python | PythonLexer
"""Tests for Latex exporter"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os.path
import textwrap
import re
from .base import ExportersTestsBase
from ..latex import LatexExporter
from IPython.nbformat import write
from IPython.nbformat import v4
from IPython.testing.decorators import onlyif_cmds_exist
from IPython.utils.tempdir import TemporaryDirectory
class TestLatexExporter(ExportersTestsBase):
"""Contains test functions for latex.py"""
exporter_class = LatexExporter
should_include_raw = ['latex']
def test_constructor(self):
"""
Can a LatexExporter be constructed?
"""
LatexExporter()
@onlyif_cmds_exist('pandoc')
def test_export(self):
"""
Can a LatexExporter export something?
"""
(output, resources) = LatexExporter().from_filename(self._get_notebook())
assert len(output) > 0
@onlyif_cmds_exist('pandoc')
def test_export_book(self):
"""
Can a LatexExporter export using 'report' template?
"""
(output, resources) = LatexExporter(template_file='report').from_filename(self._get_notebook())
assert len(output) > 0
@onlyif_cmds_exist('pandoc')
def test_export_basic(self):
"""
Can a LatexExporter export using 'article' template?
"""
(output, resources) = LatexExporter(template_file='article').from_filename(self._get_notebook())
assert len(output) > 0
@onlyif_cmds_exist('pandoc')
def test_export_article(self):
"""
Can a LatexExporter export using 'article' template?
"""
(output, resources) = LatexExporter(template_file='article').from_filename(self._get_notebook())
assert len(output) > 0
@onlyif_cmds_exist('pandoc')
def test_very_long_cells(self):
"""
Torture test that long cells do not cause issues
"""
lorem_ipsum_text = textwrap.dedent("""\
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
dignissim, ipsum non facilisis tempus, dui felis tincidunt metus,
nec pulvinar neque odio eget risus. Nulla nisi lectus, cursus
suscipit interdum at, ultrices sit amet orci. Mauris facilisis
imperdiet elit, vitae scelerisque ipsum dignissim non. Integer
consequat malesuada neque sit amet pulvinar. Curabitur pretium
ut turpis eget aliquet. Maecenas sagittis lacus sed lectus
volutpat, eu adipiscing purus pulvinar. Maecenas consequat
luctus urna, eget cursus quam mollis a. Aliquam vitae ornare
erat, non hendrerit urna. Sed eu diam nec massa egestas pharetra
at nec tellus. Fusce feugiat lacus quis urna sollicitudin volutpat.
Quisque at sapien non nibh feugiat tempus ac ultricies purus.
""")
lorem_ipsum_text = lorem_ipsum_text.replace("\n"," ") + "\n\n"
large_lorem_ipsum_text = "".join([lorem_ipsum_text]*3000)
notebook_name = "lorem_ipsum_long.ipynb"
nb = v4.new_notebook(
cells=[
v4.new_markdown_cell(source=large_lorem_ipsum_text)
]
)
with TemporaryDirectory() as td:
nbfile = os.path.join(td, notebook_name)
with open(nbfile, 'w') as f:
write(nb, f, 4)
(output, resources) = LatexExporter(template_file='article').from_filename(nbfile)
assert len(output) > 0
@onlyif_cmds_exist('pandoc')
def test_prompt_number_color(self):
"""
Does LatexExporter properly format input and output prompts in color?
"""
(output, resources) = LatexExporter().from_filename(
self._get_notebook(nb_name="prompt_numbers.ipynb"))
in_regex = r"In \[\{\\color\{incolor\}(.*)\}\]:"
out_regex = r"Out\[\{\\color\{outcolor\}(.*)\}\]:"
ins = ["2", "10", " ", " ", "*", "0"]
outs = ["10"]
assert re.findall(in_regex, output) == ins
assert re.findall(out_regex, output) == outs