From 6220c36f046b2b504cc2ebbbc04a34c4d826564d 2013-08-29 19:52:16 From: Thomas Kluyver Date: 2013-08-29 19:52:16 Subject: [PATCH] Add test for StoreMagics.autorestore option --- diff --git a/IPython/extensions/tests/test_storemagic.py b/IPython/extensions/tests/test_storemagic.py index ac6fb97..203ffd4 100644 --- a/IPython/extensions/tests/test_storemagic.py +++ b/IPython/extensions/tests/test_storemagic.py @@ -1,5 +1,6 @@ import tempfile, os +from IPython.config.loader import Config import nose.tools as nt ip = get_ipython() @@ -30,3 +31,20 @@ def test_store_restore(): nt.assert_in(os.path.realpath(tmpd), ip.user_ns['_dh']) os.rmdir(tmpd) + +def test_autorestore(): + ip.user_ns['foo'] = 95 + ip.magic('store foo') + del ip.user_ns['foo'] + c = Config() + c.StoreMagics.autorestore = False + orig_config = ip.config + try: + ip.config = c + ip.extension_manager.reload_extension('storemagic') + nt.assert_not_in('foo', ip.user_ns) + c.StoreMagics.autorestore = True + ip.extension_manager.reload_extension('storemagic') + nt.assert_equal(ip.user_ns['foo'], 95) + finally: + ip.config = orig_config