##// END OF EJS Templates
remove some unused comments from tests
MinRK -
Show More
@@ -1,52 +1,50 b''
1 """Tests for the notebook kernel and session manager"""
1 """Tests for the notebook kernel and session manager"""
2
2
3 from subprocess import PIPE
3 from subprocess import PIPE
4 import time
4 import time
5 from unittest import TestCase
5 from unittest import TestCase
6
6
7 from IPython.testing import decorators as dec
7 from IPython.testing import decorators as dec
8
8
9 from IPython.config.loader import Config
9 from IPython.config.loader import Config
10 from IPython.kernel import KernelManager
10 from IPython.kernel import KernelManager
11
11
12 class TestKernelManager(TestCase):
12 class TestKernelManager(TestCase):
13
13
14 def _get_tcp_km(self):
14 def _get_tcp_km(self):
15 c = Config()
15 c = Config()
16 # c.KernelManager.autorestart=False
17 km = KernelManager(config=c)
16 km = KernelManager(config=c)
18 return km
17 return km
19
18
20 def _get_ipc_km(self):
19 def _get_ipc_km(self):
21 c = Config()
20 c = Config()
22 c.KernelManager.transport = 'ipc'
21 c.KernelManager.transport = 'ipc'
23 c.KernelManager.ip = 'test'
22 c.KernelManager.ip = 'test'
24 # c.KernelManager.autorestart=False
25 km = KernelManager(config=c)
23 km = KernelManager(config=c)
26 return km
24 return km
27
25
28 def _run_lifecycle(self, km):
26 def _run_lifecycle(self, km):
29 km.start_kernel(stdout=PIPE, stderr=PIPE)
27 km.start_kernel(stdout=PIPE, stderr=PIPE)
30 self.assertTrue(km.is_alive())
28 self.assertTrue(km.is_alive())
31 km.restart_kernel()
29 km.restart_kernel()
32 self.assertTrue(km.is_alive())
30 self.assertTrue(km.is_alive())
33 # We need a delay here to give the restarting kernel a chance to
31 # We need a delay here to give the restarting kernel a chance to
34 # restart. Otherwise, the interrupt will kill it, causing the test
32 # restart. Otherwise, the interrupt will kill it, causing the test
35 # suite to hang. The reason it *hangs* is that the shutdown
33 # suite to hang. The reason it *hangs* is that the shutdown
36 # message for the restart sometimes hasn't been sent to the kernel.
34 # message for the restart sometimes hasn't been sent to the kernel.
37 # Because linger is oo on the shell channel, the context can't
35 # Because linger is oo on the shell channel, the context can't
38 # close until the message is sent to the kernel, which is not dead.
36 # close until the message is sent to the kernel, which is not dead.
39 time.sleep(1.0)
37 time.sleep(1.0)
40 km.interrupt_kernel()
38 km.interrupt_kernel()
41 self.assertTrue(isinstance(km, KernelManager))
39 self.assertTrue(isinstance(km, KernelManager))
42 km.shutdown_kernel()
40 km.shutdown_kernel()
43
41
44 def test_tcp_lifecycle(self):
42 def test_tcp_lifecycle(self):
45 km = self._get_tcp_km()
43 km = self._get_tcp_km()
46 self._run_lifecycle(km)
44 self._run_lifecycle(km)
47
45
48 @dec.skip_win32
46 @dec.skip_win32
49 def test_ipc_lifecycle(self):
47 def test_ipc_lifecycle(self):
50 km = self._get_ipc_km()
48 km = self._get_ipc_km()
51 self._run_lifecycle(km)
49 self._run_lifecycle(km)
52
50
@@ -1,87 +1,85 b''
1 """Tests for the notebook kernel and session manager."""
1 """Tests for the notebook kernel and session manager."""
2
2
3 from subprocess import PIPE
3 from subprocess import PIPE
4 import time
4 import time
5 from unittest import TestCase
5 from unittest import TestCase
6
6
7 from IPython.testing import decorators as dec
7 from IPython.testing import decorators as dec
8
8
9 from IPython.config.loader import Config
9 from IPython.config.loader import Config
10 from IPython.utils.localinterfaces import LOCALHOST
10 from IPython.utils.localinterfaces import LOCALHOST
11 from IPython.kernel import KernelManager
11 from IPython.kernel import KernelManager
12 from IPython.kernel.multikernelmanager import MultiKernelManager
12 from IPython.kernel.multikernelmanager import MultiKernelManager
13
13
14 class TestKernelManager(TestCase):
14 class TestKernelManager(TestCase):
15
15
16 def _get_tcp_km(self):
16 def _get_tcp_km(self):
17 c = Config()
17 c = Config()
18 # c.KernelManager.autorestart=False
19 km = MultiKernelManager(config=c)
18 km = MultiKernelManager(config=c)
20 return km
19 return km
21
20
22 def _get_ipc_km(self):
21 def _get_ipc_km(self):
23 c = Config()
22 c = Config()
24 c.KernelManager.transport = 'ipc'
23 c.KernelManager.transport = 'ipc'
25 c.KernelManager.ip = 'test'
24 c.KernelManager.ip = 'test'
26 # c.KernelManager.autorestart=False
27 km = MultiKernelManager(config=c)
25 km = MultiKernelManager(config=c)
28 return km
26 return km
29
27
30 def _run_lifecycle(self, km):
28 def _run_lifecycle(self, km):
31 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
29 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
32 self.assertTrue(km.is_alive(kid))
30 self.assertTrue(km.is_alive(kid))
33 self.assertTrue(kid in km)
31 self.assertTrue(kid in km)
34 self.assertTrue(kid in km.list_kernel_ids())
32 self.assertTrue(kid in km.list_kernel_ids())
35 self.assertEqual(len(km),1)
33 self.assertEqual(len(km),1)
36 km.restart_kernel(kid)
34 km.restart_kernel(kid)
37 self.assertTrue(km.is_alive(kid))
35 self.assertTrue(km.is_alive(kid))
38 self.assertTrue(kid in km.list_kernel_ids())
36 self.assertTrue(kid in km.list_kernel_ids())
39 # We need a delay here to give the restarting kernel a chance to
37 # We need a delay here to give the restarting kernel a chance to
40 # restart. Otherwise, the interrupt will kill it, causing the test
38 # restart. Otherwise, the interrupt will kill it, causing the test
41 # suite to hang. The reason it *hangs* is that the shutdown
39 # suite to hang. The reason it *hangs* is that the shutdown
42 # message for the restart sometimes hasn't been sent to the kernel.
40 # message for the restart sometimes hasn't been sent to the kernel.
43 # Because linger is oo on the shell channel, the context can't
41 # Because linger is oo on the shell channel, the context can't
44 # close until the message is sent to the kernel, which is not dead.
42 # close until the message is sent to the kernel, which is not dead.
45 time.sleep(1.0)
43 time.sleep(1.0)
46 km.interrupt_kernel(kid)
44 km.interrupt_kernel(kid)
47 k = km.get_kernel(kid)
45 k = km.get_kernel(kid)
48 self.assertTrue(isinstance(k, KernelManager))
46 self.assertTrue(isinstance(k, KernelManager))
49 km.shutdown_kernel(kid)
47 km.shutdown_kernel(kid)
50 self.assertTrue(not kid in km)
48 self.assertTrue(not kid in km)
51
49
52 def _run_cinfo(self, km, transport, ip):
50 def _run_cinfo(self, km, transport, ip):
53 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
51 kid = km.start_kernel(stdout=PIPE, stderr=PIPE)
54 k = km.get_kernel(kid)
52 k = km.get_kernel(kid)
55 cinfo = km.get_connection_info(kid)
53 cinfo = km.get_connection_info(kid)
56 self.assertEqual(transport, cinfo['transport'])
54 self.assertEqual(transport, cinfo['transport'])
57 self.assertEqual(ip, cinfo['ip'])
55 self.assertEqual(ip, cinfo['ip'])
58 self.assertTrue('stdin_port' in cinfo)
56 self.assertTrue('stdin_port' in cinfo)
59 self.assertTrue('iopub_port' in cinfo)
57 self.assertTrue('iopub_port' in cinfo)
60 stream = km.connect_iopub(kid)
58 stream = km.connect_iopub(kid)
61 stream.close()
59 stream.close()
62 self.assertTrue('shell_port' in cinfo)
60 self.assertTrue('shell_port' in cinfo)
63 stream = km.connect_shell(kid)
61 stream = km.connect_shell(kid)
64 stream.close()
62 stream.close()
65 self.assertTrue('hb_port' in cinfo)
63 self.assertTrue('hb_port' in cinfo)
66 stream = km.connect_hb(kid)
64 stream = km.connect_hb(kid)
67 stream.close()
65 stream.close()
68 km.shutdown_kernel(kid)
66 km.shutdown_kernel(kid)
69
67
70 def test_tcp_lifecycle(self):
68 def test_tcp_lifecycle(self):
71 km = self._get_tcp_km()
69 km = self._get_tcp_km()
72 self._run_lifecycle(km)
70 self._run_lifecycle(km)
73
71
74 def test_tcp_cinfo(self):
72 def test_tcp_cinfo(self):
75 km = self._get_tcp_km()
73 km = self._get_tcp_km()
76 self._run_cinfo(km, 'tcp', LOCALHOST)
74 self._run_cinfo(km, 'tcp', LOCALHOST)
77
75
78 @dec.skip_win32
76 @dec.skip_win32
79 def test_ipc_lifecycle(self):
77 def test_ipc_lifecycle(self):
80 km = self._get_ipc_km()
78 km = self._get_ipc_km()
81 self._run_lifecycle(km)
79 self._run_lifecycle(km)
82
80
83 @dec.skip_win32
81 @dec.skip_win32
84 def test_ipc_cinfo(self):
82 def test_ipc_cinfo(self):
85 km = self._get_ipc_km()
83 km = self._get_ipc_km()
86 self._run_cinfo(km, 'ipc', 'test')
84 self._run_cinfo(km, 'ipc', 'test')
87
85
General Comments 0
You need to be logged in to leave comments. Login now