test_types.py
This file
Path
tests/test_types.py
34 lines · 841 bytes · Python
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than c7d957c point at it.
🐛 Avoid printing additional output with `no_args_is_help=True` and Click 8.2 (#1278)Sofie Van Landeghembefore adoptionc7d957c
lines 1–34why, one step back1from enum import Enum23import typer4from typer.testing import CliRunner56app = typer.Typer(context_settings={"token_normalize_func": str.lower})789class User(str, Enum):10 rick = "Rick"11 morty = "Morty"121314@app.command()15def hello(name: User = User.rick) -> None:16 print(f"Hello {name.value}!")171819runner = CliRunner()202122def test_enum_choice() -> None:23 # This test is only for coverage of the new custom TyperChoice class24 result = runner.invoke(app, ["--name", "morty"], catch_exceptions=False)25 assert result.exit_code == 026 assert "Hello Morty!" in result.output2728 result = runner.invoke(app, ["--name", "Rick"])29 assert result.exit_code == 030 assert "Hello Rick!" in result.output3132 result = runner.invoke(app, ["--name", "RICK"])33 assert result.exit_code == 034 assert "Hello Rick!" in result.output