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