def test_prefilter_shadowed():
def dummy_magic(line): pass
prev_automagic_state = ip.automagic
ip.automagic = True
ip.autocall = 0
try:
# These should not be transformed - they are shadowed by other names
for name in ['if', 'zip', 'get_ipython']: # keyword, builtin, global
ip.register_magic_function(dummy_magic, magic_name=name)
res = ip.prefilter(name+' foo')
nt.assert_equal(res, name+' foo')
del ip.magics_manager.magics['line'][name]
# These should be transformed
for name in ['fi', 'piz', 'nohtypi_teg']:
ip.register_magic_function(dummy_magic, magic_name=name)
res = ip.prefilter(name+' foo')
nt.assert_not_equal(res, name+' foo')
del ip.magics_manager.magics['line'][name]
finally:
ip.automagic = prev_automagic_state
评论列表
文章目录