##// END OF EJS Templates
Merge pull request #8297 from minrk/rm-parallel...
Merge pull request #8297 from minrk/rm-parallel remove ipython_parallel

File last commit:

r21146:76a328da
r21226:879a45e2 merge
Show More
test_console.py
64 lines | 1.8 KiB | text/x-python | PythonLexer
Min RK
use traitlets.tests.utils for help output tests...
r21146 """Tests for two-process terminal frontend"""
MinRK
add single two-process terminal test
r5630
Min RK
use traitlets.tests.utils for help output tests...
r21146 # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
MinRK
add single two-process terminal test
r5630
MinRK
use `python -m IPython` in test_console as well
r11357 import sys
MinRK
add single two-process terminal test
r5630
from nose import SkipTest
Min RK
use traitlets.tests.utils for help output tests...
r21146 from traitlets.tests.utils import check_help_all_output
MinRK
add single two-process terminal test
r5630 from IPython.testing import decorators as dec
@dec.skip_win32
def test_console_starts():
"""test that `ipython console` starts a terminal"""
Paul Ivanov
refactor starting and stopping pexpect
r13819 p, pexpect, t = start_console()
MinRK
add single two-process terminal test
r5630 p.sendline('5')
MinRK
single timeout value for pexepect in test_console
r11796 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
Paul Ivanov
refactor starting and stopping pexpect
r13819 stop_console(p, pexpect, t)
MinRK
test that `-h` and `--help-all` work for various IPython entry points...
r12354
def test_help_output():
"""ipython console --help-all works"""
Min RK
use traitlets.tests.utils for help output tests...
r21146 check_help_all_output('jupyter_console')
Paul Ivanov
test for text/plain display handling in console
r13818
def test_display_text():
"Ensure display protocol plain/text key is supported"
# equivalent of:
#
# x = %lsmagic
# from IPython.display import display; display(x);
Paul Ivanov
refactor starting and stopping pexpect
r13819 p, pexpect, t = start_console()
p.sendline('x = %lsmagic')
idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
p.sendline('from IPython.display import display; display(x);')
p.expect([r'Available line magics:', pexpect.EOF], timeout=t)
stop_console(p, pexpect, t)
def stop_console(p, pexpect, t):
"Stop a running `ipython console` running via pexpect"
# send ctrl-D;ctrl-D to exit
p.sendeof()
p.sendeof()
p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
if p.isalive():
p.terminate()
Paul Ivanov
test for text/plain display handling in console
r13818
Paul Ivanov
refactor starting and stopping pexpect
r13819 def start_console():
"Start `ipython console` using pexpect"
MinRK
remove pexpect from external...
r20815 import pexpect
Paul Ivanov
test for text/plain display handling in console
r13818
Matthias Bussonnier
drop some 2.6 hacks
r18037 args = ['-m', 'IPython', 'console', '--colors=NoColor']
cmd = sys.executable
Paul Ivanov
test for text/plain display handling in console
r13818
try:
p = pexpect.spawn(cmd, args=args)
except IOError:
raise SkipTest("Couldn't find command %s" % cmd)
# timeout after one minute
t = 60
idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
Paul Ivanov
refactor starting and stopping pexpect
r13819 return p, pexpect, t