Show More
@@ -1,74 +1,77 b'' | |||
|
1 | 1 | """Test embedding of IPython""" |
|
2 | 2 | |
|
3 | 3 | #----------------------------------------------------------------------------- |
|
4 | 4 | # Copyright (C) 2013 The IPython Development Team |
|
5 | 5 | # |
|
6 | 6 | # Distributed under the terms of the BSD License. The full license is in |
|
7 | 7 | # the file COPYING, distributed as part of this software. |
|
8 | 8 | #----------------------------------------------------------------------------- |
|
9 | 9 | |
|
10 | 10 | #----------------------------------------------------------------------------- |
|
11 | 11 | # Imports |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | 14 | import os |
|
15 | 15 | import sys |
|
16 | 16 | from IPython.testing.decorators import skip_win32 |
|
17 | 17 | |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | # Tests |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | @skip_win32 |
|
23 | 23 | def test_debug_magic_passes_through_generators(): |
|
24 | 24 | """ |
|
25 | 25 | This test that we can correctly pass through frames of a generator post-mortem. |
|
26 | 26 | """ |
|
27 | 27 | import pexpect |
|
28 | 28 | import re |
|
29 | 29 | in_prompt = re.compile(br'In ?\[\d+\]:') |
|
30 | 30 | ipdb_prompt = 'ipdb>' |
|
31 | 31 | env = os.environ.copy() |
|
32 | 32 | child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor', '--simple-prompt'], |
|
33 | 33 | env=env) |
|
34 |
child.timeout = |
|
|
34 | child.timeout = 15 | |
|
35 | 35 | |
|
36 | 36 | child.expect(in_prompt) |
|
37 | ||
|
38 | child.timeout = 2 | |
|
39 | ||
|
37 | 40 | child.sendline("def f(x):") |
|
38 | 41 | child.sendline(" raise Exception") |
|
39 | 42 | child.sendline("") |
|
40 | 43 | |
|
41 | 44 | child.expect(in_prompt) |
|
42 | 45 | child.sendline("gen = (f(x) for x in [0])") |
|
43 | 46 | child.sendline("") |
|
44 | 47 | |
|
45 | 48 | child.expect(in_prompt) |
|
46 | 49 | child.sendline("for x in gen:") |
|
47 | 50 | child.sendline(" pass") |
|
48 | 51 | child.sendline("") |
|
49 | 52 | |
|
50 | 53 | child.expect('Exception:') |
|
51 | 54 | |
|
52 | 55 | child.expect(in_prompt) |
|
53 | 56 | child.sendline(r'%debug') |
|
54 | 57 | child.expect('----> 2 raise Exception') |
|
55 | 58 | |
|
56 | 59 | child.expect(ipdb_prompt) |
|
57 | 60 | child.sendline('u') |
|
58 | 61 | child.expect_exact(r'----> 1 gen = (f(x) for x in [0])') |
|
59 | 62 | |
|
60 | 63 | child.expect(ipdb_prompt) |
|
61 | 64 | child.sendline('u') |
|
62 | 65 | child.expect_exact('----> 1 for x in gen:') |
|
63 | 66 | |
|
64 | 67 | child.expect(ipdb_prompt) |
|
65 | 68 | child.sendline('u') |
|
66 | 69 | child.expect_exact('*** Oldest frame') |
|
67 | 70 | |
|
68 | 71 | child.expect(ipdb_prompt) |
|
69 | 72 | child.sendline('exit') |
|
70 | 73 | |
|
71 | 74 | child.expect(in_prompt) |
|
72 | 75 | child.sendline('exit') |
|
73 | 76 | |
|
74 | 77 | child.close() |
General Comments 0
You need to be logged in to leave comments.
Login now