Skip to content

Commit

Permalink
Add test for deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg committed Sep 13, 2024
1 parent 97e1dfe commit 0461b41
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions tests/test_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from typing import Optional

import pytest
import typer
from typer.testing import CliRunner

runner = CliRunner()


def test_deprecation():
app = typer.Typer()

def add_command():
@app.command()
def cmd(
opt: Optional[float] = typer.Option(
3.14,
is_flag=True,
flag_value="42",
help="Some wonderful number",
),
): ... # pragma: no cover

with pytest.warns(
match="The 'is_flag' and 'flag_value' parameters are not supported by Typer"
):
add_command()
2 changes: 1 addition & 1 deletion typer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def __init__(

warnings.warn(
"The 'is_flag' and 'flag_value' parameters are not supported by Typer "
" and will be removed entirely in a future release.",
"and will be removed entirely in a future release.",
DeprecationWarning,
stacklevel=2,
)
Expand Down

0 comments on commit 0461b41

Please sign in to comment.