##// END OF EJS Templates
First step in reintegrating Jedi...
First step in reintegrating Jedi If Jedi is installed expose a private API use it with prompt toolkit. Jedi does not _yet_ provide all the completion IPython has, so this is still a bit awkward. In order to debug this (and see what is Jedi provided we for now inject a fake Jedi/IPython delimiter in the menu. Jedi completion and this behavior are enabled by default, but could likely be opt-in. Add also a number of debug flags to be able to track why jedi is not working, and/or what completions are found by IPython and not Jedi. That should give us a bit of heads up and feedback to know whether we can remove part of the IPython completer, and more especially if we can drop `python_matches`. Once `python_matches` is dropped and some other of the current matchers are either dropped or converted to the new API, that should simplify the internal quite a bit. That would just be too much for an already BIG pull-request.

File last commit:

r23063:0820403e
r23284:3ff1be2e
Show More
test_latextools.py
134 lines | 3.7 KiB | text/x-python | PythonLexer
/ IPython / lib / tests / test_latextools.py
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 # encoding: utf-8
"""Tests for IPython.utils.path.py"""
Min RK
remove testing.tools.monkeypatch...
r21116 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Srinivas Reddy Thatiparthy
remove code specific to python2
r23063 from unittest.mock import patch
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 import nose.tools as nt
from IPython.lib import latextools
Thomas Kluyver
Fix IPython.lib.latextools for Python 3
r8013 from IPython.testing.decorators import onlyif_cmds_exist, skipif_not_matplotlib
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 from IPython.utils.process import FindCmdError
def test_latex_to_png_dvipng_fails_when_no_cmd():
"""
`latex_to_png_dvipng` should return None when there is no required command
"""
for command in ['latex', 'dvipng']:
yield (check_latex_to_png_dvipng_fails_when_no_cmd, command)
def check_latex_to_png_dvipng_fails_when_no_cmd(command):
def mock_find_cmd(arg):
if arg == command:
raise FindCmdError
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "find_cmd", mock_find_cmd):
Min RK
fix some deprecations...
r22742 nt.assert_equal(latextools.latex_to_png_dvipng("whatever", True),
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 None)
@onlyif_cmds_exist('latex', 'dvipng')
def test_latex_to_png_dvipng_runs():
"""
Test that latex_to_png_dvipng just runs without error.
"""
def mock_kpsewhich(filename):
Min RK
fix some deprecations...
r22742 nt.assert_equal(filename, "breqn.sty")
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 return None
Thomas Kluyver
Fix test for latextools under Python 2...
r19890 for (s, wrap) in [(u"$$x^2$$", False), (u"x^2", True)]:
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 yield (latextools.latex_to_png_dvipng, s, wrap)
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "kpsewhich", mock_kpsewhich):
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 yield (latextools.latex_to_png_dvipng, s, wrap)
Thomas Kluyver
Fix IPython.lib.latextools for Python 3
r8013 @skipif_not_matplotlib
def test_latex_to_png_mpl_runs():
"""
Test that latex_to_png_mpl just runs without error.
"""
def mock_kpsewhich(filename):
Min RK
fix some deprecations...
r22742 nt.assert_equal(filename, "breqn.sty")
Thomas Kluyver
Fix IPython.lib.latextools for Python 3
r8013 return None
for (s, wrap) in [("$x^2$", False), ("x^2", True)]:
yield (latextools.latex_to_png_mpl, s, wrap)
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "kpsewhich", mock_kpsewhich):
Thomas Kluyver
Fix IPython.lib.latextools for Python 3
r8013 yield (latextools.latex_to_png_mpl, s, wrap)
@skipif_not_matplotlib
def test_latex_to_html():
img = latextools.latex_to_html("$x^2$")
nt.assert_in("data:image/png;base64,iVBOR", img)
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858
def test_genelatex_no_wrap():
"""
Test genelatex with wrap=False.
"""
def mock_kpsewhich(filename):
assert False, ("kpsewhich should not be called "
"(called with {0})".format(filename))
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "kpsewhich", mock_kpsewhich):
Min RK
fix some deprecations...
r22742 nt.assert_equal(
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 '\n'.join(latextools.genelatex("body text", False)),
r'''\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\pagestyle{empty}
\begin{document}
body text
\end{document}''')
def test_genelatex_wrap_with_breqn():
"""
Test genelatex with wrap=True for the case breqn.sty is installed.
"""
def mock_kpsewhich(filename):
Min RK
fix some deprecations...
r22742 nt.assert_equal(filename, "breqn.sty")
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 return "path/to/breqn.sty"
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "kpsewhich", mock_kpsewhich):
Min RK
fix some deprecations...
r22742 nt.assert_equal(
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 '\n'.join(latextools.genelatex("x^2", True)),
r'''\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{breqn}
\pagestyle{empty}
\begin{document}
\begin{dmath*}
x^2
\end{dmath*}
\end{document}''')
def test_genelatex_wrap_without_breqn():
"""
Test genelatex with wrap=True for the case breqn.sty is not installed.
"""
def mock_kpsewhich(filename):
Min RK
fix some deprecations...
r22742 nt.assert_equal(filename, "breqn.sty")
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 return None
Min RK
remove testing.tools.monkeypatch...
r21116 with patch.object(latextools, "kpsewhich", mock_kpsewhich):
Min RK
fix some deprecations...
r22742 nt.assert_equal(
Takafumi Arakaki
Add tests for IPython.lib.latextools
r7858 '\n'.join(latextools.genelatex("x^2", True)),
r'''\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{bm}
\pagestyle{empty}
\begin{document}
$$x^2$$
\end{document}''')