MCPcopy Index your code
hub / github.com/ipython/ipython / test_alias_lifecycle

Function test_alias_lifecycle

tests/test_alias.py:6–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def test_alias_lifecycle():
7 name = "test_alias1"
8 cmd = 'echo "Hello"'
9 am = _ip.alias_manager
10 am.clear_aliases()
11 am.define_alias(name, cmd)
12 assert am.is_alias(name)
13 assert am.retrieve_alias(name) == cmd
14 assert (name, cmd) in am.aliases
15
16 # Test running the alias
17 orig_system = _ip.system
18 result = []
19 _ip.system = result.append
20 try:
21 _ip.run_cell("%{}".format(name))
22 result = [c.strip() for c in result]
23 assert result == [cmd]
24 finally:
25 _ip.system = orig_system
26
27 # Test removing the alias
28 am.undefine_alias(name)
29 assert not am.is_alias(name)
30 with pytest.raises(ValueError):
31 am.retrieve_alias(name)
32 assert (name, cmd) not in am.aliases
33
34
35def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…