MCPcopy Create free account
hub / github.com/ipython/ipython / test_alias_magic

Function test_alias_magic

IPython/core/tests/test_magic.py:1054–1076  ·  view source on GitHub ↗

Test %alias_magic.

()

Source from the content-addressed store, hash-verified

1052 nt.assert_true(mm.magics['line']['foo'].__self__ is foo2)
1053
1054def test_alias_magic():
1055 """Test %alias_magic."""
1056 ip = get_ipython()
1057 mm = ip.magics_manager
1058
1059 # Basic operation: both cell and line magics are created, if possible.
1060 ip.run_line_magic('alias_magic', 'timeit_alias timeit')
1061 nt.assert_in('timeit_alias', mm.magics['line'])
1062 nt.assert_in('timeit_alias', mm.magics['cell'])
1063
1064 # --cell is specified, line magic not created.
1065 ip.run_line_magic('alias_magic', '--cell timeit_cell_alias timeit')
1066 nt.assert_not_in('timeit_cell_alias', mm.magics['line'])
1067 nt.assert_in('timeit_cell_alias', mm.magics['cell'])
1068
1069 # Test that line alias is created successfully.
1070 ip.run_line_magic('alias_magic', '--line env_alias env')
1071 nt.assert_equal(ip.run_line_magic('env', ''),
1072 ip.run_line_magic('env_alias', ''))
1073
1074 # Test that line alias with parameters passed in is created successfully.
1075 ip.run_line_magic('alias_magic', '--line history_alias history --params ' + shlex.quote('3'))
1076 nt.assert_in('history_alias', mm.magics['line'])
1077
1078
1079def test_save():

Callers

nothing calls this directly

Calls 2

get_ipythonFunction · 0.90
run_line_magicMethod · 0.80

Tested by

no test coverage detected