Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions typer/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ def invoke( # type: ignore
color: bool = False,
**extra: Any,
) -> Result:
"""Invokes a Typer application in an isolated environment.

This is a Typer-specific wrapper around Click's CliRunner.invoke() method.
The arguments are forwarded directly to the command line script, the `extra`
keyword arguments are passed to the :meth:`~click.Command.main` function of
the command.

This returns a :class:`click.testing.Result` object.

:param app: the Typer application to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
:param extra: the keyword arguments to pass to :meth:`main`.
"""
use_cli = _get_command(app)
return super().invoke(
use_cli,
Expand Down
Loading