##// END OF EJS Templates
Add test for storemagic
Thomas Kluyver -
Show More
@@ -0,0 +1,32 b''
1 import tempfile, os
2
3 import nose.tools as nt
4
5 ip = get_ipython()
6 ip.magic('load_ext storemagic')
7
8 def test_store_restore():
9 ip.user_ns['foo'] = 78
10 ip.magic('alias bar echo "hello"')
11 tmpd = tempfile.mkdtemp()
12 ip.magic('cd ' + tmpd)
13 ip.magic('store foo')
14 ip.magic('store bar')
15
16 # Check storing
17 nt.assert_equal(ip.db['autorestore/foo'], 78)
18 nt.assert_in('bar', ip.db['stored_aliases'])
19
20 # Remove those items
21 ip.user_ns.pop('foo', None)
22 ip.alias_manager.undefine_alias('bar')
23 ip.magic('cd -')
24 ip.user_ns['_dh'][:] = []
25
26 # Check restoring
27 ip.magic('store -r')
28 nt.assert_equal(ip.user_ns['foo'], 78)
29 nt.assert_in('bar', ip.alias_manager.alias_table)
30 nt.assert_in(tmpd, ip.user_ns['_dh'])
31
32 os.rmdir(tmpd)
General Comments 0
You need to be logged in to leave comments. Login now