Show More
@@ -29,33 +29,11 b' from IPython.utils import py3compat' | |||||
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 | p, pexpect, t = start_console() | |
33 |
|
||||
34 | args = ['console', '--colors=NoColor'] |
|
|||
35 | # FIXME: remove workaround for 2.6 support |
|
|||
36 | if sys.version_info[:2] > (2,6): |
|
|||
37 | args = ['-m', 'IPython'] + args |
|
|||
38 | cmd = sys.executable |
|
|||
39 | else: |
|
|||
40 | cmd = 'ipython' |
|
|||
41 |
|
||||
42 | try: |
|
|||
43 | p = pexpect.spawn(cmd, args=args) |
|
|||
44 | except IOError: |
|
|||
45 | raise SkipTest("Couldn't find command %s" % cmd) |
|
|||
46 |
|
||||
47 | # timeout after one minute |
|
|||
48 | t = 60 |
|
|||
49 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) |
|
|||
50 | p.sendline('5') |
|
33 | p.sendline('5') | |
51 | idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t) |
|
34 | idx = p.expect([r'Out\[\d+\]: 5', pexpect.EOF], timeout=t) | |
52 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) |
|
35 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) | |
53 | # send ctrl-D;ctrl-D to exit |
|
36 | stop_console(p, pexpect, t) | |
54 | p.sendeof() |
|
|||
55 | p.sendeof() |
|
|||
56 | p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t) |
|
|||
57 | if p.isalive(): |
|
|||
58 | p.terminate() |
|
|||
59 |
|
37 | |||
60 | def test_help_output(): |
|
38 | def test_help_output(): | |
61 | """ipython console --help-all works""" |
|
39 | """ipython console --help-all works""" | |
@@ -68,7 +46,25 b' def test_display_text():' | |||||
68 | # |
|
46 | # | |
69 | # x = %lsmagic |
|
47 | # x = %lsmagic | |
70 | # from IPython.display import display; display(x); |
|
48 | # from IPython.display import display; display(x); | |
|
49 | p, pexpect, t = start_console() | |||
|
50 | p.sendline('x = %lsmagic') | |||
|
51 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) | |||
|
52 | p.sendline('from IPython.display import display; display(x);') | |||
|
53 | p.expect([r'Available line magics:', pexpect.EOF], timeout=t) | |||
|
54 | stop_console(p, pexpect, t) | |||
|
55 | ||||
|
56 | def stop_console(p, pexpect, t): | |||
|
57 | "Stop a running `ipython console` running via pexpect" | |||
|
58 | # send ctrl-D;ctrl-D to exit | |||
|
59 | p.sendeof() | |||
|
60 | p.sendeof() | |||
|
61 | p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t) | |||
|
62 | if p.isalive(): | |||
|
63 | p.terminate() | |||
|
64 | ||||
71 |
|
65 | |||
|
66 | def start_console(): | |||
|
67 | "Start `ipython console` using pexpect" | |||
72 | from IPython.external import pexpect |
|
68 | from IPython.external import pexpect | |
73 |
|
69 | |||
74 | args = ['console', '--colors=NoColor'] |
|
70 | args = ['console', '--colors=NoColor'] | |
@@ -87,14 +83,4 b' def test_display_text():' | |||||
87 | # timeout after one minute |
|
83 | # timeout after one minute | |
88 | t = 60 |
|
84 | t = 60 | |
89 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) |
|
85 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) | |
90 | p.sendline('x = %lsmagic') |
|
86 | return p, pexpect, t | |
91 | idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=t) |
|
|||
92 | p.sendline('from IPython.display import display; display(x);') |
|
|||
93 | p.expect([r'Available line magics:', pexpect.EOF], timeout=t) |
|
|||
94 |
|
||||
95 | # send ctrl-D;ctrl-D to exit |
|
|||
96 | p.sendeof() |
|
|||
97 | p.sendeof() |
|
|||
98 | p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t) |
|
|||
99 | if p.isalive(): |
|
|||
100 | p.terminate() |
|
General Comments 0
You need to be logged in to leave comments.
Login now