diff --git a/ops/pebble.py b/ops/pebble.py index dadb3cd6e..7c2419f60 100644 --- a/ops/pebble.py +++ b/ops/pebble.py @@ -1322,7 +1322,7 @@ def _wait(self) -> int: exit_code = change.tasks[0].data.get('exit-code', -1) return exit_code - def wait_output(self) -> Tuple[Optional[AnyStr], Optional[AnyStr]]: + def wait_output(self) -> Tuple[AnyStr, Optional[AnyStr]]: """Wait for the process to finish and return tuple of (stdout, stderr). If a timeout was specified to the :meth:`Client.exec` call, this waits @@ -1350,7 +1350,7 @@ def wait_output(self) -> Tuple[Optional[AnyStr], Optional[AnyStr]]: exit_code: int = self._wait() - out_value = typing.cast(AnyStr, out.getvalue()) if out is not None else None + out_value = typing.cast(AnyStr, out.getvalue()) err_value = typing.cast(AnyStr, err.getvalue()) if err is not None else None if exit_code != 0: raise ExecError[AnyStr](self._command, exit_code, out_value, err_value) diff --git a/ops/testing.py b/ops/testing.py index 96439943c..68e66b648 100755 --- a/ops/testing.py +++ b/ops/testing.py @@ -111,10 +111,10 @@ @dataclasses.dataclass class ExecArgs: - """Represent arguments captured from the :meth:`ops.model.Container.exec` method call. + """Represent arguments captured from the :meth:`ops.Container.exec` method call. - These arguments will be passed to the :class:`ops.testing.ExecHandler` handler function. - See :meth:`ops.model.Container.exec` for documentation of properties. + These arguments will be passed to the ``ops.testing.ExecHandler`` handler function. + See :meth:`ops.Container.exec` for documentation of properties. """ command: List[str] environment: Dict[str, str] @@ -134,7 +134,7 @@ class ExecResult: """Represents the result of a simulated process execution. This class is typically used to return the output and exit code from the - :class:`ops.testing.ExecHandler` handler function. + ``ops.testing.ExecHandler`` handler function. """ exit_code: int = 0 stdout: Union[str, bytes] = b"" @@ -1591,7 +1591,7 @@ def handle_exec(self, """Register a handler to simulate the pebble command execution. This allows a test harness to simulate the behavior of running commands in a container. - When :meth:`ops.model.Container.exec` is triggered, the registered handler is used to + When :meth:`ops.Container.exec` is triggered, the registered handler is used to simulate the process execution. You can provide: @@ -1613,7 +1613,7 @@ def handle_exec(self, The execution handler receives the timeout value in ExecArgs. If needed, it can raise a TimeoutError to inform the harness of a timeout occurrence. - If :meth:`ops.model.Container.exec` is called with ``combine_stderr=True``, the execution + If :meth:`ops.Container.exec` is called with ``combine_stderr=True``, the execution handler should, if required, weave the simulated standard error into the standard output. The harness checks the result and will raise an exception if stderr is non-empty. @@ -2878,7 +2878,6 @@ def remove_path(self, path: str, *, recursive: bool = False): file_path.unlink() def _find_exec_handler(self, command: List[str]) -> Optional[ExecHandler]: - print(self._exec_handlers) for command_prefix, handler in self._exec_handlers: if tuple(command[:len(command_prefix)]) == command_prefix: return handler