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