Permalink
Browse files

separate %reset tests for finer granularity

  • Loading branch information...
1 parent 01ddba0 commit d09084b6d2e491f786be335ddf096453370dc66d @ivanov committed Jan 26, 2012
Showing with 9 additions and 6 deletions.
  1. +9 −6 IPython/core/tests/test_magic.py
View
15 IPython/core/tests/test_magic.py
@@ -193,9 +193,8 @@ def test_numpy_reset_array_undec():
_ip.magic('reset -f array')
yield (nt.assert_false, 'a' in _ip.user_ns)
-def test_reset_args():
- "Test '%reset' magic with args which used to be extensions.clearcmd"
- _ip = get_ipython()
+def test_reset_out():
+ "Test '%reset out' magic"
_ip.run_cell("parrot = 'dead'", store_history=True)
# test '%reset -f out', make an Out prompt
_ip.run_cell("parrot", store_history=True)
@@ -204,23 +203,27 @@ def test_reset_args():
nt.assert_false('dead' in [_ip.user_ns[x] for x in '_','__','___'])
nt.assert_true(len(_ip.user_ns['Out']) == 0)
+def test_reset_in():
+ "Test '%reset in' magic"
# test '%reset -f in'
_ip.run_cell("parrot", store_history=True)
nt.assert_true('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
_ip.magic('%reset -f in')
nt.assert_false('parrot' in [_ip.user_ns[x] for x in '_i','_ii','_iii'])
nt.assert_true(len(set(_ip.user_ns['In'])) == 1)
- # test '%reset -f dhist'
+def test_reset_dhist():
+ "Test '%reset dhist' magic"
_ip.run_cell("tmp = [d for d in _dh]") # copy before clearing
- _ip.magic('cd')
+ _ip.magic('cd ' + os.path.dirname(nt.__file__))
_ip.magic('cd -')
nt.assert_true(len(_ip.user_ns['_dh']) > 0)
_ip.magic('reset -f dhist')
nt.assert_true(len(_ip.user_ns['_dh']) == 0)
_ip.run_cell("_dh = [d for d in tmp]") #restore
- # test that In length is preserved for %macro
+def test_reset_in_length():
+ "Test that '%reset in' preserves In[] length"
_ip.run_cell("print 'foo'")
_ip.run_cell("reset -f in")
nt.assert_true(len(_ip.user_ns['In']) == _ip.displayhook.prompt_count+1)

0 comments on commit d09084b

Please sign in to comment.