Show More
@@ -92,8 +92,10 This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code.""" | |||
|
92 | 92 | |
|
93 | 93 | LineFrontEndBase.__init__(self, *args, **kwargs) |
|
94 | 94 | # XXX: Hack: mix the two namespaces |
|
95 |
self.shell.user_ns |
|
|
96 | self.shell.user_global_ns = self.ipython0.user_global_ns | |
|
95 | self.shell.user_ns.update(self.ipython0.user_ns) | |
|
96 | self.ipython0.user_ns = self.shell.user_ns | |
|
97 | self.shell.user_global_ns.update(self.ipython0.user_global_ns) | |
|
98 | self.ipython0.user_global_ns = self.shell.user_global_ns | |
|
97 | 99 | |
|
98 | 100 | self.shell.output_trap = RedirectorOutputTrap( |
|
99 | 101 | out_callback=self.write, |
@@ -17,6 +17,7 import string | |||
|
17 | 17 | |
|
18 | 18 | from IPython.ipapi import get as get_ipython0 |
|
19 | 19 | from IPython.frontend.prefilterfrontend import PrefilterFrontEnd |
|
20 | from copy import deepcopy | |
|
20 | 21 | |
|
21 | 22 | class TestPrefilterFrontEnd(PrefilterFrontEnd): |
|
22 | 23 | |
@@ -49,6 +50,23 class TestPrefilterFrontEnd(PrefilterFrontEnd): | |||
|
49 | 50 | PrefilterFrontEnd._on_enter(self) |
|
50 | 51 | |
|
51 | 52 | |
|
53 | def isolate_ipython0(func): | |
|
54 | """ Decorator to isolate execution that involves an iptyhon0. | |
|
55 | """ | |
|
56 | def my_func(*args, **kwargs): | |
|
57 | ipython0 = get_ipython0().IP | |
|
58 | user_ns = deepcopy(ipython0.user_ns) | |
|
59 | global_ns = deepcopy(ipython0.global_ns) | |
|
60 | try: | |
|
61 | func(*args, **kwargs) | |
|
62 | finally: | |
|
63 | ipython0.user_ns = user_ns | |
|
64 | ipython0.global_ns = global_ns | |
|
65 | ||
|
66 | return my_func | |
|
67 | ||
|
68 | ||
|
69 | @isolate_ipython0 | |
|
52 | 70 | def test_execution(): |
|
53 | 71 | """ Test execution of a command. |
|
54 | 72 | """ |
@@ -59,6 +77,7 def test_execution(): | |||
|
59 | 77 | assert out_value == '1\n' |
|
60 | 78 | |
|
61 | 79 | |
|
80 | @isolate_ipython0 | |
|
62 | 81 | def test_multiline(): |
|
63 | 82 | """ Test execution of a multiline command. |
|
64 | 83 | """ |
@@ -84,6 +103,7 def test_multiline(): | |||
|
84 | 103 | assert out_value == '1\n' |
|
85 | 104 | |
|
86 | 105 | |
|
106 | @isolate_ipython0 | |
|
87 | 107 | def test_capture(): |
|
88 | 108 | """ Test the capture of output in different channels. |
|
89 | 109 | """ |
@@ -102,6 +122,7 def test_capture(): | |||
|
102 | 122 | assert out_value == '1' |
|
103 | 123 | |
|
104 | 124 | |
|
125 | @isolate_ipython0 | |
|
105 | 126 | def test_magic(): |
|
106 | 127 | """ Test the magic expansion and history. |
|
107 | 128 | |
@@ -114,6 +135,7 def test_magic(): | |||
|
114 | 135 | assert out_value == 'Interactive namespace is empty.\n' |
|
115 | 136 | |
|
116 | 137 | |
|
138 | @isolate_ipython0 | |
|
117 | 139 | def test_help(): |
|
118 | 140 | """ Test object inspection. |
|
119 | 141 | """ |
@@ -133,6 +155,7 def test_help(): | |||
|
133 | 155 | #assert out_value.split()[-1] == 'foobar' |
|
134 | 156 | |
|
135 | 157 | |
|
158 | @isolate_ipython0 | |
|
136 | 159 | def test_completion(): |
|
137 | 160 | """ Test command-line completion. |
|
138 | 161 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now