| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import pytest
- from src.commands import COMMANDS
- def test_help_returns_nonempty_string():
- result = COMMANDS["help"]()
- assert isinstance(result, str)
- assert len(result) > 0
- def test_help_mentions_help_command():
- result = COMMANDS["help"]()
- assert "help" in result
- def test_unknown_command_not_in_registry():
- assert "foobar" not in COMMANDS
- def test_all_commands_are_callable():
- for name, handler in COMMANDS.items():
- assert callable(handler), f"Command '{name}' is not callable"
- def test_exit_raises_system_exit(capsys):
- with pytest.raises(SystemExit) as exc_info:
- COMMANDS["exit"]()
- assert exc_info.value.code == 0
- def test_exit_prints_goodbye(capsys):
- with pytest.raises(SystemExit):
- COMMANDS["exit"]()
- captured = capsys.readouterr()
- assert "Goodbye!" in captured.out
- def test_exit_is_in_registry():
- assert "exit" in COMMANDS
- def test_help_mentions_exit():
- result = COMMANDS["help"]()
- assert "exit" in result
|