##// END OF EJS Templates
Merge pull request #1656 from minrk/embed_kernel_tests...
Merge pull request #1656 from minrk/embed_kernel_tests ensure kernels are cleaned up in embed_kernel tests use contextmanager to ensure kernel manager sockets are closed at the end of tests, preventing delayed 'could not close sockets' errors in later tests. closes #1653

File last commit:

r5629:ba0b0dbd
r6657:8bfca101 merge
Show More
test_kernelsession.py
27 lines | 819 B | text/x-python | PythonLexer
"""Tests for the notebook kernel and session manager."""
from unittest import TestCase
from IPython.frontend.html.notebook.kernelmanager import MultiKernelManager
class TestKernelManager(TestCase):
def test_km_lifecycle(self):
km = MultiKernelManager()
kid = km.start_kernel()
self.assert_(kid in km)
self.assertEquals(len(km),1)
km.kill_kernel(kid)
self.assert_(not kid in km)
kid = km.start_kernel()
self.assertEquals('127.0.0.1',km.get_kernel_ip(kid))
port_dict = km.get_kernel_ports(kid)
self.assert_('stdin_port' in port_dict)
self.assert_('iopub_port' in port_dict)
self.assert_('shell_port' in port_dict)
self.assert_('hb_port' in port_dict)
km.get_kernel(kid)
km.kill_kernel(kid)