55
66
77def setup_module ():
8- ip .magic ('load_ext storemagic' )
8+ ip .run_line_magic ("load_ext" , "storemagic" )
9+
910
1011def test_store_restore ():
11- assert 'bar' not in ip .user_ns , "Error: some other test leaked `bar` in user_ns"
12- assert 'foo' not in ip .user_ns , "Error: some other test leaked `foo` in user_ns"
13- assert 'foobar' not in ip .user_ns , "Error: some other test leaked `foobar` in user_ns"
14- assert 'foobaz' not in ip .user_ns , "Error: some other test leaked `foobaz` in user_ns"
15- ip .user_ns ['foo' ] = 78
16- ip .magic ('alias bar echo "hello"' )
17- ip .user_ns ['foobar' ] = 79
18- ip .user_ns ['foobaz' ] = '80'
12+ assert "bar" not in ip .user_ns , "Error: some other test leaked `bar` in user_ns"
13+ assert "foo" not in ip .user_ns , "Error: some other test leaked `foo` in user_ns"
14+ assert (
15+ "foobar" not in ip .user_ns
16+ ), "Error: some other test leaked `foobar` in user_ns"
17+ assert (
18+ "foobaz" not in ip .user_ns
19+ ), "Error: some other test leaked `foobaz` in user_ns"
20+ ip .user_ns ["foo" ] = 78
21+ ip .run_line_magic ("alias" , 'bar echo "hello"' )
22+ ip .user_ns ["foobar" ] = 79
23+ ip .user_ns ["foobaz" ] = "80"
1924 tmpd = tempfile .mkdtemp ()
20- ip .magic ( 'cd ' + tmpd )
21- ip .magic ( ' store foo' )
22- ip .magic ( ' store bar' )
23- ip .magic ( ' store foobar foobaz' )
25+ ip .run_line_magic ( "cd" , tmpd )
26+ ip .run_line_magic ( " store" , " foo" )
27+ ip .run_line_magic ( " store" , " bar" )
28+ ip .run_line_magic ( " store" , " foobar foobaz" )
2429
2530 # Check storing
2631 assert ip .db ["autorestore/foo" ] == 78
@@ -29,29 +34,29 @@ def test_store_restore():
2934 assert ip .db ["autorestore/foobaz" ] == "80"
3035
3136 # Remove those items
32- ip .user_ns .pop (' foo' , None )
33- ip .user_ns .pop (' foobar' , None )
34- ip .user_ns .pop (' foobaz' , None )
35- ip .alias_manager .undefine_alias (' bar' )
36- ip .magic ( 'cd -' )
37- ip .user_ns [' _dh' ][:] = []
37+ ip .user_ns .pop (" foo" , None )
38+ ip .user_ns .pop (" foobar" , None )
39+ ip .user_ns .pop (" foobaz" , None )
40+ ip .alias_manager .undefine_alias (" bar" )
41+ ip .run_line_magic ( "cd" , "-" )
42+ ip .user_ns [" _dh" ][:] = []
3843
3944 # Check restoring
40- ip .magic ("store -r foo bar foobar foobaz" )
45+ ip .run_line_magic ("store" , " -r foo bar foobar foobaz" )
4146 assert ip .user_ns ["foo" ] == 78
4247 assert ip .alias_manager .is_alias ("bar" )
4348 assert ip .user_ns ["foobar" ] == 79
4449 assert ip .user_ns ["foobaz" ] == "80"
4550
46- ip .magic ("store -r" ) # restores _dh too
51+ ip .run_line_magic ("store" , " -r" ) # restores _dh too
4752 assert any (Path (tmpd ).samefile (p ) for p in ip .user_ns ["_dh" ])
4853
4954 os .rmdir (tmpd )
5055
5156def test_autorestore ():
52- ip .user_ns [' foo' ] = 95
53- ip .magic ( ' store foo' )
54- del ip .user_ns [' foo' ]
57+ ip .user_ns [" foo" ] = 95
58+ ip .run_line_magic ( " store" , " foo" )
59+ del ip .user_ns [" foo" ]
5560 c = Config ()
5661 c .StoreMagics .autorestore = False
5762 orig_config = ip .config
0 commit comments