##// END OF EJS Templates
Merge pull request #7665 from jdfreder/fixedmodeindi2...
Merge pull request #7665 from jdfreder/fixedmodeindi2 Fix the mode indicator width.

File last commit:

r19881:9c5bd693
r20310:2e4fbcff merge
Show More
test_kernel.py
69 lines | 2.1 KiB | text/x-python | PythonLexer
MinRK
msgspec 5: stream.data -> stream.text
r18104 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475
from __future__ import print_function
epatters
BUG: raw_input logic incorrect for in-process terminal frontend.
r8482 import sys
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475 import unittest
MinRK
update inprocess kernel to new layout...
r10298 from IPython.kernel.inprocess.blocking import BlockingInProcessKernelClient
from IPython.kernel.inprocess.manager import InProcessKernelManager
MinRK
move IPython.inprocess to IPython.kernel.inprocess
r9375 from IPython.kernel.inprocess.ipkernel import InProcessKernel
Min RK
use assemble_output in in-process kernel test...
r19881 from IPython.kernel.tests.utils import assemble_output
epatters
TST: Skip pylab test for in-process kernel when matplotlib is missing.
r8493 from IPython.testing.decorators import skipif_not_matplotlib
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475 from IPython.utils.io import capture_output
Pietro Berkes
BUG: In inprocess tests, use input/raw_input depending on Python version.
r8941 from IPython.utils import py3compat
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475
Thomas Kluyver
Use StringIO.StringIO on Python 2....
r13366 if py3compat.PY3:
from io import StringIO
else:
from StringIO import StringIO
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475
class InProcessKernelTestCase(unittest.TestCase):
MinRK
update inprocess kernel to new layout...
r10298 def setUp(self):
self.km = InProcessKernelManager()
self.km.start_kernel()
self.kc = BlockingInProcessKernelClient(kernel=self.km.kernel)
self.kc.start_channels()
Thomas Kluyver
Collapse inprocess channel classes together
r19223 self.kc.wait_for_ready()
MinRK
update inprocess kernel to new layout...
r10298
epatters
TST: Skip pylab test for in-process kernel when matplotlib is missing.
r8493 @skipif_not_matplotlib
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475 def test_pylab(self):
MinRK
msgspec 5: stream.data -> stream.text
r18104 """Does %pylab work in the in-process kernel?"""
MinRK
update inprocess kernel to new layout...
r10298 kc = self.kc
kc.execute('%pylab')
Min RK
use assemble_output in in-process kernel test...
r19881 out, err = assemble_output(kc.iopub_channel)
self.assertIn('matplotlib', out)
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475
epatters
BUG: raw_input logic incorrect for in-process terminal frontend.
r8482 def test_raw_input(self):
""" Does the in-process kernel handle raw_input correctly?
"""
io = StringIO('foobar\n')
sys_stdin = sys.stdin
sys.stdin = io
try:
Pietro Berkes
BUG: In inprocess tests, use input/raw_input depending on Python version.
r8941 if py3compat.PY3:
MinRK
update inprocess kernel to new layout...
r10298 self.kc.execute('x = input()')
Pietro Berkes
BUG: In inprocess tests, use input/raw_input depending on Python version.
r8941 else:
MinRK
update inprocess kernel to new layout...
r10298 self.kc.execute('x = raw_input()')
epatters
BUG: raw_input logic incorrect for in-process terminal frontend.
r8482 finally:
sys.stdin = sys_stdin
MinRK
update inprocess kernel to new layout...
r10298 self.assertEqual(self.km.kernel.shell.user_ns.get('x'), 'foobar')
epatters
BUG: raw_input logic incorrect for in-process terminal frontend.
r8482
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475 def test_stdout(self):
""" Does the in-process kernel correctly capture IO?
"""
kernel = InProcessKernel()
with capture_output() as io:
kernel.shell.run_cell('print("foo")')
self.assertEqual(io.stdout, 'foo\n')
MinRK
update inprocess kernel to new layout...
r10298 kc = BlockingInProcessKernelClient(kernel=kernel)
kernel.frontends.append(kc)
Thomas Kluyver
Use messaging methods on kernel client instead of channel objects
r19213 kc.execute('print("bar")')
Min RK
use assemble_output in in-process kernel test...
r19881 out, err = assemble_output(kc.iopub_channel)
self.assertEqual(out, 'bar\n')
epatters
TST: Add some unit tests for in-process kernel and kernel manager.
r8475