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-02-09 12:36 +0000

1from typer.testing import CliRunner 1abcdefgh

2 

3from docs_src.commands.index import tutorial005_py39 as mod 1abcdefgh

4 

5app = mod.app 1abcdefgh

6runner = CliRunner() 1abcdefgh

7 

8 

9def test_creates_successfully(): 1abcdefgh

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

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

12 assert result.exit_code == 0 1abcdefgh

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

14 

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

16 assert result.exit_code == 0 1abcdefgh

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

18 

19 

20def test_shows_suggestion(): 1abcdefgh

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

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

23 assert result.exit_code != 0 1abcdefgh

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