##// 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 193 _ip.magic('reset -f array')
194 194 yield (nt.assert_false, 'a' in _ip.user_ns)
195 195
196 def test_reset_args():
197 "Test '%reset' magic with args which used to be extensions.clearcmd"
198 _ip = get_ipython()
196 def test_reset_out():
197 "Test '%reset out' magic"
199 198 _ip.run_cell("parrot = 'dead'", store_history=True)
200 199 # test '%reset -f out', make an Out prompt
201 200 _ip.run_cell("parrot", store_history=True)
@@ -204,6 +203,8 b' def test_reset_args():'
204 203 nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
205 204 nt.assert_true(len(_ip.user_ns['Out']) == 0)
206 205
206 def test_reset_in():
207 "Test '%reset in' magic"
207 208 # test '%reset -f in'
208 209 _ip.run_cell("parrot", store_history=True)
209 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 212 nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
212 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 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 219 _ip.magic('cd -')
218 220 nt.assert_true(len(_ip.user_ns['_dh']) > 0)
219 221 _ip.magic('reset -f dhist')
220 222 nt.assert_true(len(_ip.user_ns['_dh']) == 0)
221 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 227 _ip.run_cell("print 'foo'")
225 228 _ip.run_cell("reset -f in")
226 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