Show More
@@ -0,0 +1,52 b'' | |||||
|
1 | """Test embedding of IPython""" | |||
|
2 | ||||
|
3 | #----------------------------------------------------------------------------- | |||
|
4 | # Copyright (C) 2013 The IPython Development Team | |||
|
5 | # | |||
|
6 | # Distributed under the terms of the BSD License. The full license is in | |||
|
7 | # the file COPYING, distributed as part of this software. | |||
|
8 | #----------------------------------------------------------------------------- | |||
|
9 | ||||
|
10 | #----------------------------------------------------------------------------- | |||
|
11 | # Imports | |||
|
12 | #----------------------------------------------------------------------------- | |||
|
13 | ||||
|
14 | import sys | |||
|
15 | import nose.tools as nt | |||
|
16 | from IPython.utils.process import process_handler | |||
|
17 | ||||
|
18 | #----------------------------------------------------------------------------- | |||
|
19 | # Tests | |||
|
20 | #----------------------------------------------------------------------------- | |||
|
21 | ||||
|
22 | _sample_embed = """ | |||
|
23 | from __future__ import print_function | |||
|
24 | import IPython | |||
|
25 | ||||
|
26 | a = 3 | |||
|
27 | b = 14 | |||
|
28 | print(a, '.', b) | |||
|
29 | ||||
|
30 | IPython.embed() | |||
|
31 | ||||
|
32 | print 'bye!' | |||
|
33 | """ | |||
|
34 | ||||
|
35 | def test_ipython_embed(): | |||
|
36 | """test that `ipython [subcommand] --help-all` works""" | |||
|
37 | #with TempFile as f: | |||
|
38 | # f.write("some embed case goes here") | |||
|
39 | ||||
|
40 | # run `python file_with_embed.py` | |||
|
41 | fname = '/home/pi/code/workspace/rambles/test_embed.py' | |||
|
42 | cmd = [sys.executable, fname] | |||
|
43 | ||||
|
44 | #p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) | |||
|
45 | print "\nhere's the command:", cmd | |||
|
46 | _, out, p = process_handler(cmd, | |||
|
47 | lambda p: (p.stdin.write("exit\r"), p.communicate()[:], p)) | |||
|
48 | print out[1] | |||
|
49 | nt.assert_equal(p.returncode, 0) | |||
|
50 | nt.assert_equal(p.returncode, 0) | |||
|
51 | #out, err, rc = tt.get_output_error_code(cmd) | |||
|
52 |
@@ -27,7 +27,7 b' else:' | |||||
27 | from ._process_posix import _find_cmd, system, getoutput, arg_split |
|
27 | from ._process_posix import _find_cmd, system, getoutput, arg_split | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | from ._process_common import getoutputerror, get_output_error_code |
|
30 | from ._process_common import getoutputerror, get_output_error_code, process_handler | |
31 | from . import py3compat |
|
31 | from . import py3compat | |
32 |
|
32 | |||
33 | #----------------------------------------------------------------------------- |
|
33 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now