diff --git a/IPython/terminal/tests/test_embed.py b/IPython/terminal/tests/test_embed.py new file mode 100644 index 0000000..d54df8f --- /dev/null +++ b/IPython/terminal/tests/test_embed.py @@ -0,0 +1,52 @@ +"""Test embedding of IPython""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2013 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import sys +import nose.tools as nt +from IPython.utils.process import process_handler + +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- + +_sample_embed = """ +from __future__ import print_function +import IPython + +a = 3 +b = 14 +print(a, '.', b) + +IPython.embed() + +print 'bye!' +""" + +def test_ipython_embed(): + """test that `ipython [subcommand] --help-all` works""" + #with TempFile as f: + # f.write("some embed case goes here") + + # run `python file_with_embed.py` + fname = '/home/pi/code/workspace/rambles/test_embed.py' + cmd = [sys.executable, fname] + + #p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) + print "\nhere's the command:", cmd + _, out, p = process_handler(cmd, + lambda p: (p.stdin.write("exit\r"), p.communicate()[:], p)) + print out[1] + nt.assert_equal(p.returncode, 0) + nt.assert_equal(p.returncode, 0) +#out, err, rc = tt.get_output_error_code(cmd) + diff --git a/IPython/utils/process.py b/IPython/utils/process.py index 3eed415..826aa51 100644 --- a/IPython/utils/process.py +++ b/IPython/utils/process.py @@ -27,7 +27,7 @@ else: from ._process_posix import _find_cmd, system, getoutput, arg_split -from ._process_common import getoutputerror, get_output_error_code +from ._process_common import getoutputerror, get_output_error_code, process_handler from . import py3compat #-----------------------------------------------------------------------------