##// END OF EJS Templates
single timeout value for pexepect in test_console
MinRK -
Show More
@@ -1,55 +1,57 b''
1 """Tests for two-process terminal frontend
1 """Tests for two-process terminal frontend
2
2
3 Currently only has the most simple test possible, starting a console and running
3 Currently only has the most simple test possible, starting a console and running
4 a single command.
4 a single command.
5
5
6 Authors:
6 Authors:
7
7
8 * Min RK
8 * Min RK
9 """
9 """
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 import sys
15 import sys
16 import time
16 import time
17
17
18 import nose.tools as nt
18 import nose.tools as nt
19 from nose import SkipTest
19 from nose import SkipTest
20
20
21 from IPython.testing import decorators as dec
21 from IPython.testing import decorators as dec
22 from IPython.utils import py3compat
22 from IPython.utils import py3compat
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 # Test functions begin
25 # Test functions begin
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27
27
28 @dec.skip_win32
28 @dec.skip_win32
29 def test_console_starts():
29 def test_console_starts():
30 """test that `ipython console` starts a terminal"""
30 """test that `ipython console` starts a terminal"""
31 from IPython.external import pexpect
31 from IPython.external import pexpect
32
32
33 args = ['console', '--colors=NoColor']
33 args = ['console', '--colors=NoColor']
34 # FIXME: remove workaround for 2.6 support
34 # FIXME: remove workaround for 2.6 support
35 if sys.version_info[:2] > (2,6):
35 if sys.version_info[:2] > (2,6):
36 args = ['-m', 'IPython'] + args
36 args = ['-m', 'IPython'] + args
37 cmd = sys.executable
37 cmd = sys.executable
38 else:
38 else:
39 cmd = 'ipython'
39 cmd = 'ipython'
40
40
41 try:
41 try:
42 p = pexpect.spawn(cmd, args=args)
42 p = pexpect.spawn(cmd, args=args)
43 except IOError:
43 except IOError:
44 raise SkipTest("Couldn't find command %s" % cmd)
44 raise SkipTest("Couldn't find command %s" % cmd)
45
45
46 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=45)
46 # timeout after one minute
47 t = 60
48 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
47 p.sendline('5')
49 p.sendline('5')
48 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=15)
50 idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t)
49 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=15)
51 idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t)
50 # send ctrl-D;ctrl-D to exit
52 # send ctrl-D;ctrl-D to exit
51 p.sendeof()
53 p.sendeof()
52 p.sendeof()
54 p.sendeof()
53 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=30)
55 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
54 if p.isalive():
56 if p.isalive():
55 p.terminate()
57 p.terminate()
General Comments 0
You need to be logged in to leave comments. Login now