##// END OF EJS Templates
tests for %clear extension
Paul Ivanov -
Show More
@@ -183,12 +183,10 b' def test_macro_run():'
183 with tt.AssertPrints("13"):
183 with tt.AssertPrints("13"):
184 ip.run_cell("test")
184 ip.run_cell("test")
185
185
186
186
187 # XXX failing for now, until we get clearcmd out of quarantine. But we should
187 @dec.skipif_not_numpy
188 # fix this and revert the skip to happen only if numpy is not around.
189 #@dec.skipif_not_numpy
190 @dec.skip_known_failure
191 def test_numpy_clear_array_undec():
188 def test_numpy_clear_array_undec():
189 "Test '%clear array' functionality"
192 from IPython.extensions import clearcmd
190 from IPython.extensions import clearcmd
193
191
194 _ip.ex('import numpy as np')
192 _ip.ex('import numpy as np')
@@ -196,7 +194,34 b' def test_numpy_clear_array_undec():'
196 yield (nt.assert_true, 'a' in _ip.user_ns)
194 yield (nt.assert_true, 'a' in _ip.user_ns)
197 _ip.magic('clear array')
195 _ip.magic('clear array')
198 yield (nt.assert_false, 'a' in _ip.user_ns)
196 yield (nt.assert_false, 'a' in _ip.user_ns)
199
197
198 def test_clear():
199 "Test '%clear' magic provided by IPython.extensions.clearcmd"
200 from IPython.extensions import clearcmd
201 _ip = get_ipython()
202 _ip.run_cell("parrot = 'dead'", store_history=True)
203 # test '%clear out', make an Out prompt
204 _ip.run_cell("parrot", store_history=True)
205 nt.assert_true('dead' in [_ip.user_ns[x] for x in '_','__','___'])
206 _ip.magic('clear out')
207 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
208 nt.assert_true(len(_ip.user_ns['Out']) ==0)
209
210 # test '%clear in'
211 _ip.run_cell("parrot", store_history=True)
212 nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
213 _ip.magic('%clear in')
214 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
215 nt.assert_true(len(_ip.user_ns['In'] ==0))
216
217 # test '%clear dhist'
218 _ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
219 _ip.magic('cd')
220 _ip.magic('cd -')
221 nt.assert_true(len(_ip.user_ns['_dh']) > 0)
222 _ip.magic('clear dhist')
223 nt.assert_true(len(_ip.user_ns['_dh']) == 0)
224 _ip.run_cell("_dh = [d for d in tmp]") #restore
200
225
201 def test_time():
226 def test_time():
202 _ip.magic('time None')
227 _ip.magic('time None')
General Comments 0
You need to be logged in to leave comments. Login now