✨ Add custom CliRunner and Click imports
This commit is contained in:
parent
c2214d2ea5
commit
eff740c844
2 changed files with 67 additions and 1 deletions
|
@ -5,4 +5,43 @@ __version__ = "0.0.1"
|
|||
from .main import Typer, run # noqa
|
||||
from .params import Option, Argument # noqa
|
||||
from .models import Context, TextFile, BinaryFileRead, BinaryFileWrite # noqa
|
||||
from click import echo # noqa
|
||||
|
||||
# Utilities
|
||||
from click.utils import ( # noqa
|
||||
echo,
|
||||
get_binary_stream,
|
||||
get_text_stream,
|
||||
open_file,
|
||||
format_filename,
|
||||
get_app_dir,
|
||||
get_os_args,
|
||||
)
|
||||
|
||||
# Terminal functions
|
||||
from click.termui import ( # noqa
|
||||
prompt,
|
||||
confirm,
|
||||
get_terminal_size,
|
||||
echo_via_pager,
|
||||
progressbar,
|
||||
clear,
|
||||
style,
|
||||
unstyle,
|
||||
secho,
|
||||
edit,
|
||||
launch,
|
||||
getchar,
|
||||
pause,
|
||||
)
|
||||
|
||||
from click.exceptions import ( # noqa
|
||||
ClickException,
|
||||
UsageError,
|
||||
BadParameter,
|
||||
FileError,
|
||||
Abort,
|
||||
NoSuchOption,
|
||||
BadOptionUsage,
|
||||
BadArgumentUsage,
|
||||
MissingParameter,
|
||||
)
|
||||
|
|
27
typer/testing.py
Normal file
27
typer/testing.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from click.testing import Result, CliRunner as ClickCliRunner # noqa
|
||||
from typer.main import get_command as _get_command
|
||||
|
||||
|
||||
class CliRunner(ClickCliRunner):
|
||||
def invoke(
|
||||
self,
|
||||
cli,
|
||||
args=None,
|
||||
input=None,
|
||||
env=None,
|
||||
catch_exceptions=True,
|
||||
color=False,
|
||||
mix_stderr=False,
|
||||
**extra
|
||||
) -> Result:
|
||||
use_cli = _get_command(cli)
|
||||
return super().invoke(
|
||||
use_cli,
|
||||
args=args,
|
||||
input=input,
|
||||
env=env,
|
||||
catch_exceptions=catch_exceptions,
|
||||
color=color,
|
||||
mix_stderr=mix_stderr,
|
||||
**extra
|
||||
)
|
Loading…
Reference in a new issue