##// END OF EJS Templates
test first element of sys.path in Kernel...
MinRK -
Show More
@@ -17,6 +17,7 b' import nose.tools as nt'
17
17
18 from IPython.testing import decorators as dec, tools as tt
18 from IPython.testing import decorators as dec, tools as tt
19 from IPython.utils import py3compat
19 from IPython.utils import py3compat
20 from IPython.utils.path import locate_profile
20
21
21 from .utils import new_kernel, kernel, TIMEOUT, assemble_output, execute, flush_channels
22 from .utils import new_kernel, kernel, TIMEOUT, assemble_output, execute, flush_channels
22
23
@@ -46,6 +47,21 b' def test_simple_print():'
46 _check_mp_mode(kc, expected=False)
47 _check_mp_mode(kc, expected=False)
47
48
48
49
50 def test_sys_path():
51 """test that sys.path doesn't get messed up by default"""
52 with kernel() as kc:
53 msg_id, content = execute(kc=kc, code="import sys; print (repr(sys.path[0]))")
54 stdout, stderr = assemble_output(kc.iopub_channel)
55 nt.assert_equal(stdout, "''\n")
56
57 def test_sys_path_profile_dir():
58 """test that sys.path doesn't get messed up when `--profile-dir` is specified"""
59
60 with new_kernel(['--profile-dir', locate_profile('default')]) as kc:
61 msg_id, content = execute(kc=kc, code="import sys; print (repr(sys.path[0]))")
62 stdout, stderr = assemble_output(kc.iopub_channel)
63 nt.assert_equal(stdout, "''\n")
64
49 @dec.knownfailureif(sys.platform == 'win32', "subprocess prints fail on Windows")
65 @dec.knownfailureif(sys.platform == 'win32', "subprocess prints fail on Windows")
50 def test_subprocess_print():
66 def test_subprocess_print():
51 """printing from forked mp.Process"""
67 """printing from forked mp.Process"""
@@ -36,10 +36,13 b' KC = None'
36 #-------------------------------------------------------------------------------
36 #-------------------------------------------------------------------------------
37
37
38
38
39 def start_new_kernel():
39 def start_new_kernel(argv=None):
40 """start a new kernel, and return its Manager and Client"""
40 """start a new kernel, and return its Manager and Client"""
41 km = KernelManager()
41 km = KernelManager()
42 km.start_kernel(stdout=PIPE, stderr=PIPE)
42 kwargs = dict(stdout=PIPE, stderr=PIPE)
43 if argv:
44 kwargs['extra_arguments'] = argv
45 km.start_kernel(**kwargs)
43 kc = km.client()
46 kc = km.client()
44 kc.start_channels()
47 kc.start_channels()
45
48
@@ -123,7 +126,7 b' def stop_global_kernel():'
123 KM = None
126 KM = None
124
127
125 @contextmanager
128 @contextmanager
126 def new_kernel():
129 def new_kernel(argv=None):
127 """Context manager for a new kernel in a subprocess
130 """Context manager for a new kernel in a subprocess
128
131
129 Should only be used for tests where the kernel must not be re-used.
132 Should only be used for tests where the kernel must not be re-used.
@@ -132,7 +135,7 b' def new_kernel():'
132 -------
135 -------
133 kernel_client: connected KernelClient instance
136 kernel_client: connected KernelClient instance
134 """
137 """
135 km, kc = start_new_kernel()
138 km, kc = start_new_kernel(argv)
136 try:
139 try:
137 yield kc
140 yield kc
138 finally:
141 finally:
General Comments 0
You need to be logged in to leave comments. Login now