LogCliRunner#

class lsst.daf.butler.cli.utils.LogCliRunner(charset: str = 'utf-8', env: Mapping[str, str | None] | None = None, echo_stdin: bool = False, catch_exceptions: bool = True)#

Bases: CliRunner

A test runner to use when the logging system will be initialized by code under test, calls CliLog.resetLog(), which undoes any logging setup that was done with the CliLog interface.

lsst.log modules can not be set back to an uninitialized state (python logging modules can be set back to NOTSET), instead they are set to CliLog.defaultLsstLogLevel.

Methods Summary

invoke(*args, **kwargs)

Invokes a command in an isolated environment.

Methods Documentation

invoke(*args: Any, **kwargs: Any) Result#

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 main() function of the command.

This returns a Result object.

Parameters:
  • cli – the command to invoke

  • 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 shlex.split().

  • input – the input data for sys.stdin.

  • env – the environment overrides.

  • catch_exceptions – Whether to catch any other exceptions than SystemExit. If None, the value from CliRunner is used.

  • extra – the keyword arguments to pass to main().

  • color – whether the output should contain color codes. The application can still override this explicitly.

Added in version 8.2: The result object has the output_bytes attribute with the mix of stdout_bytes and stderr_bytes, as the user would see it in its terminal.

Changed in version 8.2: The result object always returns the stderr_bytes stream.

Changed in version 8.0: The result object has the return_value attribute with the value returned from the invoked command.

Changed in version 4.0: Added the color parameter.

Changed in version 3.0: Added the catch_exceptions parameter.

Changed in version 3.0: The result object has the exc_info attribute with the traceback if available.