test_kernelsession.py
27 lines
| 835 B
| text/x-python
|
PythonLexer
Brian E. Granger
|
r4344 | """Tests for the notebook kernel and session manager.""" | ||
Brian E. Granger
|
r4343 | |||
from unittest import TestCase | ||||
MinRK
|
r4960 | from IPython.frontend.html.notebook.kernelmanager import MultiKernelManager | ||
Brian E. Granger
|
r4343 | |||
class TestKernelManager(TestCase): | ||||
def test_km_lifecycle(self): | ||||
MinRK
|
r4960 | km = MultiKernelManager() | ||
Brian E. Granger
|
r4343 | kid = km.start_kernel() | ||
Bradley M. Froehle
|
r7876 | self.assertTrue(kid in km) | ||
Bradley M. Froehle
|
r7874 | self.assertEqual(len(km),1) | ||
Brian E. Granger
|
r4343 | km.kill_kernel(kid) | ||
Bradley M. Froehle
|
r7876 | self.assertTrue(not kid in km) | ||
Brian E. Granger
|
r4343 | |||
kid = km.start_kernel() | ||||
Bradley M. Froehle
|
r7874 | self.assertEqual('127.0.0.1',km.get_kernel_ip(kid)) | ||
Brian E. Granger
|
r4343 | port_dict = km.get_kernel_ports(kid) | ||
Bradley M. Froehle
|
r7876 | self.assertTrue('stdin_port' in port_dict) | ||
self.assertTrue('iopub_port' in port_dict) | ||||
self.assertTrue('shell_port' in port_dict) | ||||
self.assertTrue('hb_port' in port_dict) | ||||
MinRK
|
r4960 | km.get_kernel(kid) | ||
MinRK
|
r5629 | km.kill_kernel(kid) | ||
Brian E. Granger
|
r4343 | |||