Coverage for tests / test_tutorial / test_commands / test_index / test_tutorial005.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-11-18 11:12 +0000

1from typer.testing import CliRunner 1abcdefghij

2 

3from docs_src.commands.index import tutorial005 as mod 1abcdefghij

4 

5app = mod.app 1abcdefghij

6runner = CliRunner() 1abcdefghij

7 

8 

9def test_creates_successfully(): 1abcdefghij

10 """Verify the example runs without errors""" 

11 result = runner.invoke(app, ["create"]) 1abcdefghij

12 assert result.exit_code == 0 1abcdefghij

13 assert "Creating..." in result.output 1abcdefghij

14 

15 result = runner.invoke(app, ["delete"]) 1abcdefghij

16 assert result.exit_code == 0 1abcdefghij

17 assert "Deleting..." in result.output 1abcdefghij

18 

19 

20def test_shows_suggestion(): 1abcdefghij

21 """Verify command suggestions appear for typos""" 

22 result = runner.invoke(app, ["crate"]) 1abcdefghij

23 assert result.exit_code != 0 1abcdefghij

24 assert "Did you mean 'create'?" in result.output 1abcdefghij