Skip to content

Commit

Permalink
✅ Add tests for vendored _split_opt, for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Mar 26, 2024
1 parent da4a3d2 commit fb548bf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_others.py
Expand Up @@ -10,6 +10,7 @@
import shellingham
import typer
import typer.completion
from typer.core import _split_opt
from typer.main import solve_typer_info_defaults, solve_typer_info_help
from typer.models import ParameterInfo, TyperInfo
from typer.testing import CliRunner
Expand Down Expand Up @@ -243,3 +244,21 @@ def main(name: str):

result = runner.invoke(app, ["main", "-h"])
assert "Show this message and exit." in result.stdout


def test_split_opt():
prefix, opt = _split_opt("--verbose")
assert prefix == "--"
assert opt == "verbose"

prefix, opt = _split_opt("//verbose")
assert prefix == "//"
assert opt == "verbose"

prefix, opt = _split_opt("-verbose")
assert prefix == "-"
assert opt == "verbose"

prefix, opt = _split_opt("verbose")
assert prefix == ""
assert opt == "verbose"

0 comments on commit fb548bf

Please sign in to comment.