##// END OF EJS Templates
separate %reset tests for finer granularity
Paul Ivanov -
Show More
@@ -193,9 +193,8 b' def test_numpy_reset_array_undec():'
193 _ip.magic('reset -f array')
193 _ip.magic('reset -f array')
194 yield (nt.assert_false, 'a' in _ip.user_ns)
194 yield (nt.assert_false, 'a' in _ip.user_ns)
195
195
196 def test_reset_args():
196 def test_reset_out():
197 "Test '%reset' magic with args which used to be extensions.clearcmd"
197 "Test '%reset out' magic"
198 _ip = get_ipython()
199 _ip.run_cell("parrot = 'dead'", store_history=True)
198 _ip.run_cell("parrot = 'dead'", store_history=True)
200 # test '%reset -f out', make an Out prompt
199 # test '%reset -f out', make an Out prompt
201 _ip.run_cell("parrot", store_history=True)
200 _ip.run_cell("parrot", store_history=True)
@@ -204,6 +203,8 b' def test_reset_args():'
204 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
203 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
205 nt.assert_true(len(_ip.user_ns['Out']) == 0)
204 nt.assert_true(len(_ip.user_ns['Out']) == 0)
206
205
206 def test_reset_in():
207 "Test '%reset in' magic"
207 # test '%reset -f in'
208 # test '%reset -f in'
208 _ip.run_cell("parrot", store_history=True)
209 _ip.run_cell("parrot", store_history=True)
209 nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
210 nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
@@ -211,16 +212,18 b' def test_reset_args():'
211 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
212 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
212 nt.assert_true(len(set(_ip.user_ns['In'])) == 1)
213 nt.assert_true(len(set(_ip.user_ns['In'])) == 1)
213
214
214 # test '%reset -f dhist'
215 def test_reset_dhist():
216 "Test '%reset dhist' magic"
215 _ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
217 _ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
216 _ip.magic('cd')
218 _ip.magic('cd ' + os.path.dirname(nt.__file__))
217 _ip.magic('cd -')
219 _ip.magic('cd -')
218 nt.assert_true(len(_ip.user_ns['_dh']) > 0)
220 nt.assert_true(len(_ip.user_ns['_dh']) > 0)
219 _ip.magic('reset -f dhist')
221 _ip.magic('reset -f dhist')
220 nt.assert_true(len(_ip.user_ns['_dh']) == 0)
222 nt.assert_true(len(_ip.user_ns['_dh']) == 0)
221 _ip.run_cell("_dh = [d for d in tmp]") #restore
223 _ip.run_cell("_dh = [d for d in tmp]") #restore
222
224
223 # test that In length is preserved for %macro
225 def test_reset_in_length():
226 "Test that '%reset in' preserves In[] length"
224 _ip.run_cell("print 'foo'")
227 _ip.run_cell("print 'foo'")
225 _ip.run_cell("reset -f in")
228 _ip.run_cell("reset -f in")
226 nt.assert_true(len(_ip.user_ns['In']) == _ip.displayhook.prompt_count+1)
229 nt.assert_true(len(_ip.user_ns['In']) == _ip.displayhook.prompt_count+1)
General Comments 0
You need to be logged in to leave comments. Login now