MCPcopy
hub / github.com/pallets/click / invoke

Method invoke

src/click/testing.py:596–739  ·  src/click/testing.py::CliRunner.invoke

Invokes a command in an isolated environment. The arguments are forwarded directly to the command line script, the `extra` keyword arguments are passed to the :meth:`~clickpkg.Command.main` function of the command. This returns a :class:`Result` object. :pa

(
        self,
        cli: Command,
        args: str | cabc.Sequence[str] | None = None,
        input: str | bytes | t.IO[t.Any] | None = None,
        env: cabc.Mapping[str, str | None] | None = None,
        catch_exceptions: bool | None = None,
        color: bool = False,
        **extra: t.Any,
    )

Source from the content-addressed store, hash-verified

594 pdb.Pdb.__init__ = old_pdb_init class="cm"># type: ignore[method-assign]
595
596 def invoke(
597 self,
598 cli: Command,
599 args: str | cabc.Sequence[str] | None = None,
600 input: str | bytes | t.IO[t.Any] | None = None,
601 env: cabc.Mapping[str, str | None] | None = None,
602 catch_exceptions: bool | None = None,
603 color: bool = False,
604 **extra: t.Any,
605 ) -> Result:
606 class="st">"""Invokes a command in an isolated environment. The arguments are
607 forwarded directly to the command line script, the `extra` keyword
608 arguments are passed to the :meth:`~clickpkg.Command.main` function of
609 the command.
610
611 This returns a :class:`Result` object.
612
613 :param cli: the command to invoke
614 :param args: the arguments to invoke. It may be given as an iterable
615 or a string. When given as string it will be interpreted
616 as a Unix shell command. More details at
617 :func:`shlex.split`.
618 :param input: the input data for `sys.stdin`.
619 :param env: the environment overrides.
620 :param catch_exceptions: Whether to catch any other exceptions than
621 ``SystemExit``. If :data:`None`, the value
622 from :class:`CliRunner` is used.
623 :param extra: the keyword arguments to pass to :meth:`main`.
624 :param color: whether the output should contain color codes. The
625 application can still override this explicitly.
626
627 .. versionadded:: 8.2
628 The result object has the ``output_bytes`` attribute with
629 the mix of ``stdout_bytes`` and ``stderr_bytes``, as the user would
630 see it in its terminal.
631
632 .. versionchanged:: 8.2
633 The result object always returns the ``stderr_bytes`` stream.
634
635 .. versionchanged:: 8.0
636 The result object has the ``return_value`` attribute with
637 the value returned from the invoked command.
638
639 .. versionchanged:: 4.0
640 Added the ``color`` parameter.
641
642 .. versionchanged:: 3.0
643 Added the ``catch_exceptions`` parameter.
644
645 .. versionchanged:: 3.0
646 The result object has the ``exc_info`` attribute with the
647 traceback if available.
648 class="st">"""
649 exc_info = None
650 if catch_exceptions is None:
651 catch_exceptions = self.catch_exceptions
652
653 class="cm"># Set up fd capture before isolation replaces sys.stdout and sys.stderr.

Callers 15

test_runnerFunction · 0.95
test_echo_stdin_streamFunction · 0.95
test_echo_stdin_promptsFunction · 0.95
test_runner_with_streamFunction · 0.95
test_promptsFunction · 0.95
test_getcharFunction · 0.95
test_catch_exceptionsFunction · 0.95
test_with_colorFunction · 0.95
test_with_color_errorsFunction · 0.95
test_with_echo_via_pagerFunction · 0.95

Calls 10

isolationMethod · 0.95
get_default_prog_nameMethod · 0.95
_FDCaptureClass · 0.85
ResultClass · 0.85
startMethod · 0.80
mainMethod · 0.80
stopMethod · 0.80
getvalueMethod · 0.80
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected