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