()
| 4 | |
| 5 | |
| 6 | def 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 | |
| 35 | def test_alias_args_error(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…