Show More
@@ -1,3 +1,4 b'' | |||||
|
1 | # coding: utf-8 | |||
1 | """test the IPython Kernel""" |
|
2 | """test the IPython Kernel""" | |
2 |
|
3 | |||
3 | #------------------------------------------------------------------------------- |
|
4 | #------------------------------------------------------------------------------- | |
@@ -11,6 +12,8 b'' | |||||
11 | # Imports |
|
12 | # Imports | |
12 | #------------------------------------------------------------------------------- |
|
13 | #------------------------------------------------------------------------------- | |
13 |
|
14 | |||
|
15 | import io | |||
|
16 | import os.path | |||
14 | import sys |
|
17 | import sys | |
15 |
|
18 | |||
16 | import nose.tools as nt |
|
19 | import nose.tools as nt | |
@@ -18,8 +21,10 b' import nose.tools as nt' | |||||
18 | from IPython.testing import decorators as dec, tools as tt |
|
21 | from IPython.testing import decorators as dec, tools as tt | |
19 | from IPython.utils import py3compat |
|
22 | from IPython.utils import py3compat | |
20 | from IPython.utils.path import locate_profile |
|
23 | from IPython.utils.path import locate_profile | |
|
24 | from IPython.utils.tempdir import TemporaryDirectory | |||
21 |
|
25 | |||
22 |
from .utils import new_kernel, kernel, TIMEOUT, assemble_output, execute, |
|
26 | from .utils import (new_kernel, kernel, TIMEOUT, assemble_output, execute, | |
|
27 | flush_channels, wait_for_idle) | |||
23 |
|
28 | |||
24 | #------------------------------------------------------------------------------- |
|
29 | #------------------------------------------------------------------------------- | |
25 | # Tests |
|
30 | # Tests | |
@@ -180,6 +185,22 b' def test_eval_input():' | |||||
180 | nt.assert_equal(stdout, "2\n") |
|
185 | nt.assert_equal(stdout, "2\n") | |
181 |
|
186 | |||
182 |
|
187 | |||
|
188 | def test_save_history(): | |||
|
189 | # Saving history from the kernel with %hist -f was failing because of | |||
|
190 | # unicode problems on Python 2. | |||
|
191 | with kernel() as kc, TemporaryDirectory() as td: | |||
|
192 | file = os.path.join(td, 'hist.out') | |||
|
193 | execute(u'a=1', kc=kc) | |||
|
194 | wait_for_idle(kc) | |||
|
195 | execute(u'b=u"abcþ"', kc=kc) | |||
|
196 | wait_for_idle(kc) | |||
|
197 | _, reply = execute("%hist -f " + file, kc=kc) | |||
|
198 | nt.assert_equal(reply['status'], 'ok') | |||
|
199 | with io.open(file, encoding='utf-8') as f: | |||
|
200 | content = f.read() | |||
|
201 | nt.assert_in(u'a=1', content) | |||
|
202 | nt.assert_in(u'b=u"abcþ"', content) | |||
|
203 | ||||
183 | def test_help_output(): |
|
204 | def test_help_output(): | |
184 | """ipython kernel --help-all works""" |
|
205 | """ipython kernel --help-all works""" | |
185 | tt.help_all_output_test('kernel') |
|
206 | tt.help_all_output_test('kernel') |
@@ -170,5 +170,10 b' def assemble_output(iopub):' | |||||
170 | pass |
|
170 | pass | |
171 | return stdout, stderr |
|
171 | return stdout, stderr | |
172 |
|
172 | |||
173 |
|
173 | def wait_for_idle(kc): | ||
174 |
|
174 | while True: | ||
|
175 | msg = kc.iopub_channel.get_msg(block=True, timeout=1) | |||
|
176 | msg_type = msg['msg_type'] | |||
|
177 | content = msg['content'] | |||
|
178 | if msg_type == 'status' and content['execution_state'] == 'idle': | |||
|
179 | break |
General Comments 0
You need to be logged in to leave comments.
Login now