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