launch_testing.asserts.assert_output module

A module providing process output assertions.

To prevent pytest from rewriting this module assertions, please PYTEST_DONT_REWRITE. See https://docs.pytest.org/en/latest/assert.html#disabling-assert-rewriting for further reference.

launch_testing.asserts.assert_output.assertDefaultStream()

Return the stream that is used by default for ‘assertInStream’.

This is useful for writing tests that are compatible with both Eloquent and newer releases.

launch_testing.asserts.assert_output.assertInStderr(proc_output, expected_output, process, cmd_args=None, *, output_filter=None, strict_proc_matching=True, strip_ansi_escape_sequences=True)

Assert that ‘output’ was found in the standard error of a process.

See the documentation for ‘assertInStream’ for full details.

launch_testing.asserts.assert_output.assertInStdout(proc_output, expected_output, process, cmd_args=None, *, output_filter=None, strict_proc_matching=True, strip_ansi_escape_sequences=True)

Assert that ‘output’ was found in the standard output of a process.

See the documentation for ‘assertInStream’ for full details.

launch_testing.asserts.assert_output.assertInStream(proc_output, expected_output, process, cmd_args=None, *, output_filter=None, strict_proc_matching=True, strip_ansi_escape_sequences=True, stream='stderr')

Assert that ‘output’ was found in a stream of a process.

Parameters:

proc_output – The process output captured by launch_test. This is usually injected

into test cases as self._proc_output :type proc_output: An launch_testing.IoHandler

Parameters:
  • expected_output (string or regex pattern or a list of the aforementioned types) – The output to search for

  • process (A string (search by process name) or a launch.actions.ExecuteProcess object) – The process whose output will be searched

  • cmd_args – Optional. If ‘process’ is a string, cmd_args will be used to disambiguate

processes with the same name. Pass launch_testing.asserts.NO_CMD_ARGS to match a proc without command arguments :type cmd_args: string

Parameters:
  • output_filter (callable) – Optional. A function to filter output before attempting any assertion.

  • strict_proc_matching – Optional (default True), If proc is a string and the combination

of proc and cmd_args matches multiple processes, then strict_proc_matching=True will raise an error. :type strict_proc_matching: bool

Parameters:

strip_ansi_escape_sequences – If True (default), strip ansi escape

sequences from actual output before comparing with the output filter or expected output. :type strip_ansi_escape_sequences: bool

Parameters:

stream (string) – Which stream to examine. This must be one of ‘stderr’ or ‘stdout’.