##// END OF EJS Templates
Merge pull request #4166 from minrk/localinterfaces...
Merge pull request #4166 from minrk/localinterfaces avoid executing code in utils.localinterfaces at import time

File last commit:

r12591:5d0418a8
r12635:62e35db2 merge
Show More
test_multikernelmanager.py
78 lines | 2.4 KiB | text/x-python | PythonLexer
/ IPython / kernel / tests / test_multikernelmanager.py
Brian E. Granger
Refactoring the notebook app to support the new config system.
r4344 """Tests for the notebook kernel and session manager."""
Brian E. Granger
Refactored htmlnotebook session and kernel manager....
r4343
Brian E. Granger
Fixing last few things with the test suite for kernel managers.
r9132 from subprocess import PIPE
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131 import time
Brian E. Granger
Refactored htmlnotebook session and kernel manager....
r4343 from unittest import TestCase
MinRK
skip ipc tests on Windows...
r9156 from IPython.testing import decorators as dec
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 from IPython.config.loader import Config
MinRK
avoid executing code in utils.localinterfaces at import time...
r12591 from IPython.utils.localinterfaces import localhost
MinRK
update imports with new layout
r10284 from IPython.kernel import KernelManager
MinRK
move multikernelmanager to IPython.kernel
r9371 from IPython.kernel.multikernelmanager import MultiKernelManager
Brian E. Granger
Refactored htmlnotebook session and kernel manager....
r4343
class TestKernelManager(TestCase):
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 def _get_tcp_km(self):
Brian Granger
Refactoring kernel restarting.
r10282 c = Config()
km = MultiKernelManager(config=c)
return km
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116
def _get_ipc_km(self):
c = Config()
c.KernelManager.transport = 'ipc'
c.KernelManager.ip = 'test'
km = MultiKernelManager(config=c)
return km
def _run_lifecycle(self, km):
Brian E. Granger
Fixing last few things with the test suite for kernel managers.
r9132 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
Brian E. Granger
Made is_alive a method of KernelManager and MultiKernelManager....
r10275 self.assertTrue(km.is_alive(kid))
Bradley M. Froehle
s/assert_/assertTrue/
r7876 self.assertTrue(kid in km)
Brian E. Granger
General cleanup of kernelmanger.MultiKernelManager.
r9112 self.assertTrue(kid in km.list_kernel_ids())
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(len(km),1)
MinRK
use forceful restart / shutdown in KM / MKM tests
r12416 km.restart_kernel(kid, now=True)
Brian E. Granger
Made is_alive a method of KernelManager and MultiKernelManager....
r10275 self.assertTrue(km.is_alive(kid))
Brian E. Granger
Removing return value of restart_kernel....
r9113 self.assertTrue(kid in km.list_kernel_ids())
Brian E. Granger
General cleanup of kernelmanger.MultiKernelManager.
r9112 km.interrupt_kernel(kid)
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 k = km.get_kernel(kid)
self.assertTrue(isinstance(k, KernelManager))
MinRK
use forceful restart / shutdown in KM / MKM tests
r12416 km.shutdown_kernel(kid, now=True)
Bradley M. Froehle
s/assert_/assertTrue/
r7876 self.assertTrue(not kid in km)
Brian E. Granger
Refactored htmlnotebook session and kernel manager....
r4343
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124 def _run_cinfo(self, km, transport, ip):
Brian E. Granger
Fixing last few things with the test suite for kernel managers.
r9132 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 k = km.get_kernel(kid)
cinfo = km.get_connection_info(kid)
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124 self.assertEqual(transport, cinfo['transport'])
self.assertEqual(ip, cinfo['ip'])
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 self.assertTrue('stdin_port' in cinfo)
self.assertTrue('iopub_port' in cinfo)
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 stream = km.connect_iopub(kid)
MinRK
include stream creation in notebook KM tests
r9158 stream.close()
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 self.assertTrue('shell_port' in cinfo)
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 stream = km.connect_shell(kid)
MinRK
include stream creation in notebook KM tests
r9158 stream.close()
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 self.assertTrue('hb_port' in cinfo)
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 stream = km.connect_hb(kid)
MinRK
include stream creation in notebook KM tests
r9158 stream.close()
MinRK
use forceful restart / shutdown in KM / MKM tests
r12416 km.shutdown_kernel(kid, now=True)
Brian E. Granger
Refactored htmlnotebook session and kernel manager....
r4343
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131 def test_tcp_lifecycle(self):
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124 km = self._get_tcp_km()
self._run_lifecycle(km)
def test_tcp_cinfo(self):
km = self._get_tcp_km()
MinRK
avoid executing code in utils.localinterfaces at import time...
r12591 self._run_cinfo(km, 'tcp', localhost())
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124
MinRK
skip remaining ipc test on Windows...
r9518 @dec.skip_win32
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131 def test_ipc_lifecycle(self):
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124 km = self._get_ipc_km()
self._run_lifecycle(km)
MinRK
skip remaining ipc test on Windows...
r9518 @dec.skip_win32
Brian E. Granger
Adding tested ipc support to MultiKernelManager.
r9116 def test_ipc_cinfo(self):
km = self._get_ipc_km()
Brian Granger
Cleaning up MultiKernelManager test and adding linger=0 to shell....
r9124 self._run_cinfo(km, 'ipc', 'test')
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131