##// END OF EJS Templates
add single two-process terminal test
MinRK -
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,59 b''
1 """Tests for two-process terminal frontend
2
3 Currenlty only has the most simple test possible, starting a console and running
4 a single command.
5
6 Authors:
7
8 * Min RK
9 """
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
15 import time
16
17 import nose.tools as nt
18 from nose import SkipTest
19
20 from IPython.testing import decorators as dec
21 from IPython.testing import tools as tt
22 from IPython.utils import py3compat
23 from IPython.utils.process import find_cmd
24
25 #-----------------------------------------------------------------------------
26 # Test functions begin
27 #-----------------------------------------------------------------------------
28
29 @dec.skip_win32
30 def test_console_starts():
31 """test that `ipython console` starts a terminal"""
32 from IPython.external import pexpect
33
34 # weird IOErrors prevent this from firing sometimes:
35 ipython_cmd = None
36 for i in range(5):
37 try:
38 ipython_cmd = find_cmd('ipython3' if py3compat.PY3 else 'ipython')
39 except IOError:
40 time.sleep(0.1)
41 else:
42 break
43 if ipython_cmd is None:
44 raise SkipTest("Could not determine ipython command")
45
46 p = pexpect.spawn(ipython_cmd, args=['console', '--colors=NoColor'])
47 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=4)
48 nt.assert_equals(idx, 0, "expected in prompt")
49 p.sendline('5')
50 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=1)
51 nt.assert_equals(idx, 0, "expected out prompt")
52 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=1)
53 nt.assert_equals(idx, 0, "expected second in prompt")
54 # send ctrl-D;ctrl-D to exit
55 p.sendeof()
56 p.sendeof()
57 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=1)
58 if p.isalive():
59 p.terminate()
General Comments 0
You need to be logged in to leave comments. Login now