##// END OF EJS Templates
Fix warning when running IPython.kernel tests...
Fix warning when running IPython.kernel tests The signature of TemporaryDirectory.cleanup() changed just before Python 3.2, and our TemporaryWorkingDirectory subclass was receiving an unexpected parameter. This copies in a newer TemporaryDirectory.cleanup() implementation for Python 2.7.

File last commit:

r11840:1aea7460
r12165:def58361
Show More
test_kernelmanager.py
61 lines | 1.9 KiB | text/x-python | PythonLexer
/ IPython / kernel / tests / test_kernelmanager.py
Brian E. Granger
Final cleanup of kernelmanager...
r9151 """Tests for the notebook kernel and session manager"""
Brian Granger
Adding test for basic kernel manager.
r9126
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 Granger
Adding test for basic kernel manager.
r9126 from unittest import TestCase
MinRK
skip ipc tests on Windows...
r9156 from IPython.testing import decorators as dec
Brian Granger
Adding test for basic kernel manager.
r9126 from IPython.config.loader import Config
MinRK
update imports with new layout
r10284 from IPython.kernel import KernelManager
Brian Granger
Adding test for basic kernel manager.
r9126
class TestKernelManager(TestCase):
def _get_tcp_km(self):
Brian Granger
Refactoring kernel restarting.
r10282 c = Config()
km = KernelManager(config=c)
return km
Brian Granger
Adding test for basic kernel manager.
r9126
def _get_ipc_km(self):
c = Config()
c.KernelManager.transport = 'ipc'
c.KernelManager.ip = 'test'
km = KernelManager(config=c)
return km
def _run_lifecycle(self, km):
Brian E. Granger
Fixing last few things with the test suite for kernel managers.
r9132 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())
Brian Granger
Adding test for basic kernel manager.
r9126 km.restart_kernel()
Brian E. Granger
Made is_alive a method of KernelManager and MultiKernelManager....
r10275 self.assertTrue(km.is_alive())
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131 # We need a delay here to give the restarting kernel a chance to
# restart. Otherwise, the interrupt will kill it, causing the test
# suite to hang. The reason it *hangs* is that the shutdown
# message for the restart sometimes hasn't been sent to the kernel.
# Because linger is oo on the shell channel, the context can't
# close until the message is sent to the kernel, which is not dead.
Brian E. Granger
Fixing last few things with the test suite for kernel managers.
r9132 time.sleep(1.0)
Brian Granger
Adding test for basic kernel manager.
r9126 km.interrupt_kernel()
self.assertTrue(isinstance(km, KernelManager))
km.shutdown_kernel()
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131 def test_tcp_lifecycle(self):
Brian Granger
Adding test for basic kernel manager.
r9126 km = self._get_tcp_km()
self._run_lifecycle(km)
MinRK
skip ipc tests on Windows...
r9156 @dec.skip_win32
MinRK
define and test IPython.kernel public API
r9376 def test_ipc_lifecycle(self):
Brian Granger
Adding test for basic kernel manager.
r9126 km = self._get_ipc_km()
self._run_lifecycle(km)
MinRK
test KernelManager.get_connection_info
r11840
def test_get_connect_info(self):
km = self._get_tcp_km()
cinfo = km.get_connection_info()
keys = sorted(cinfo.keys())
expected = sorted([
'ip', 'transport',
'hb_port', 'shell_port', 'stdin_port', 'iopub_port', 'control_port',
'key', 'signature_scheme',
])
self.assertEqual(keys, expected)
Brian E. Granger
Fixing bug in kernelmanager tests that was causing tests to hang....
r9131