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

Function test_alias_lifecycle

IPython/core/tests/test_alias.py:5–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import nose.tools as nt
4
5def test_alias_lifecycle():
6 name = 'test_alias1'
7 cmd = 'echo "Hello"'
8 am = _ip.alias_manager
9 am.clear_aliases()
10 am.define_alias(name, cmd)
11 assert am.is_alias(name)
12 nt.assert_equal(am.retrieve_alias(name), cmd)
13 nt.assert_in((name, cmd), am.aliases)
14
15 # Test running the alias
16 orig_system = _ip.system
17 result = []
18 _ip.system = result.append
19 try:
20 _ip.run_cell('%{}'.format(name))
21 result = [c.strip() for c in result]
22 nt.assert_equal(result, [cmd])
23 finally:
24 _ip.system = orig_system
25
26 # Test removing the alias
27 am.undefine_alias(name)
28 assert not am.is_alias(name)
29 with nt.assert_raises(ValueError):
30 am.retrieve_alias(name)
31 nt.assert_not_in((name, cmd), am.aliases)
32
33
34def test_alias_args_error():

Callers

nothing calls this directly

Calls 7

clear_aliasesMethod · 0.80
define_aliasMethod · 0.80
is_aliasMethod · 0.80
retrieve_aliasMethod · 0.80
undefine_aliasMethod · 0.80
run_cellMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected