##// END OF EJS Templates
Merge pull request #9276 from takluyver/test-embed-simple-prompt...
Kyle Kelley -
r22133:78b81f05 merge
parent child Browse files
Show More
@@ -101,9 +101,9 b' class TerminalInteractiveShell(InteractiveShell):'
101 ]
101 ]
102
102
103 def init_prompt_toolkit_cli(self):
103 def init_prompt_toolkit_cli(self):
104 if not sys.stdin.isatty():
104 if ('IPY_TEST_SIMPLE_PROMPT' in os.environ) or not sys.stdin.isatty():
105 # Piped input - e.g. for tests. Fall back to plain non-interactive
105 # Fall back to plain non-interactive output for tests.
106 # output. This is very limited, and only accepts a single line.
106 # This is very limited, and only accepts a single line.
107 def prompt():
107 def prompt():
108 return cast_unicode_py2(input('In [%d]: ' % self.execution_count))
108 return cast_unicode_py2(input('In [%d]: ' % self.execution_count))
109 self.prompt_for_code = prompt
109 self.prompt_for_code = prompt
@@ -12,9 +12,9 b''
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 import os
14 import os
15 import subprocess
15 import sys
16 import sys
16 import nose.tools as nt
17 import nose.tools as nt
17 from IPython.utils.process import process_handler
18 from IPython.utils.tempdir import NamedFileInTemporaryDirectory
18 from IPython.utils.tempdir import NamedFileInTemporaryDirectory
19 from IPython.testing.decorators import skip_win32
19 from IPython.testing.decorators import skip_win32
20
20
@@ -47,9 +47,14 b' def test_ipython_embed():'
47
47
48 # run `python file_with_embed.py`
48 # run `python file_with_embed.py`
49 cmd = [sys.executable, f.name]
49 cmd = [sys.executable, f.name]
50 env = os.environ.copy()
51 env['IPY_TEST_SIMPLE_PROMPT'] = '1'
52
53 p = subprocess.Popen(cmd, env=env, stdin=subprocess.PIPE,
54 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
55 out, err = p.communicate(_exit)
56 std = out.decode('UTF-8')
50
57
51 out, p = process_handler(cmd, lambda p: (p.communicate(_exit), p))
52 std = out[0].decode('UTF-8')
53 nt.assert_equal(p.returncode, 0)
58 nt.assert_equal(p.returncode, 0)
54 nt.assert_in('3 . 14', std)
59 nt.assert_in('3 . 14', std)
55 if os.name != 'nt':
60 if os.name != 'nt':
@@ -62,9 +67,12 b' def test_nest_embed():'
62 """test that `IPython.embed()` is nestable"""
67 """test that `IPython.embed()` is nestable"""
63 import pexpect
68 import pexpect
64 ipy_prompt = r']:' #ansi color codes give problems matching beyond this
69 ipy_prompt = r']:' #ansi color codes give problems matching beyond this
70 env = os.environ.copy()
71 env['IPY_TEST_SIMPLE_PROMPT'] = '1'
65
72
66
73
67 child = pexpect.spawn('%s -m IPython --colors=nocolor'%(sys.executable, ))
74 child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor'],
75 env=env)
68 child.expect(ipy_prompt)
76 child.expect(ipy_prompt)
69 child.sendline("from __future__ import print_function")
77 child.sendline("from __future__ import print_function")
70 child.expect(ipy_prompt)
78 child.expect(ipy_prompt)
General Comments 0
You need to be logged in to leave comments. Login now