launch_testing.asserts package

Submodules

Module contents

class launch_testing.asserts.SequentialTextChecker(output)

Bases: object

Helper class for asserting that text is found in a certain order.

assertInStdout(msg)
assertInText(msg)
get_nearby_lines()
launch_testing.asserts.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.assertExitCodes(proc_info, allowable_exit_codes=[0], process=None, cmd_args=None, *, strict_proc_matching=True)

Check the exit codes of the processes under test.

Parameters:

proc_info (iterable) – A list of proc_info objects provided by the test framework to be

checked

launch_testing.asserts.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.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.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’.

launch_testing.asserts.assertSequentialStdout(proc_output, process, cmd_args=None)

Create a context manager used to check stdout occurred in a specific order.

Parameters:
  • proc_output – The captured output from a test run

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

  • cmd_args – Optional. If ‘proc’ 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