seaworthy.stream.matchers

class CombinationMatcher(*matchers)[source]

Matcher that combines multiple input matchers.

classmethod by_equality(*expected_items)[source]

Construct an instance of this combination matcher from a list of expected items and/or StreamMatcher instances.

classmethod by_regex(*patterns)[source]

Construct an instance of this combination matcher from a list of regex patterns and/or StreamMatcher instances.

class EqualsMatcher(expected_item)[source]

Matcher that matches items by equality.

args_str()[source]

Return an args string for the repr.

match(item)[source]

Return True if the item matches the expected value exactly, otherwise False.

class OrderedMatcher(*matchers)[source]

Matcher that takes a list of matchers, and uses one after the next after each has a successful match. Returns True (“matches”) on the final match.

Note: This is a stateful matcher. Once it has done its matching, you’ll need to create a new instance.

args_str()[source]

Return an args string for the repr.

match(item)[source]

Return True if the expected matchers are matched in the expected order, otherwise False.

class RegexMatcher(pattern)[source]

Matcher that matches items by regex pattern.

args_str()[source]

Return an args string for the repr.

match(item)[source]

Return True if the item matches the expected regex, otherwise False.

class StreamMatcher[source]

Abstract base class for stream matchers.

args_str()[source]

Return an args string for the repr.

match(item)[source]

Return True if the matcher matches an item, otherwise False.

class UnorderedMatcher(*matchers)[source]

Matcher that takes a list of matchers, and matches each one to an item. Each item is tested against each unmatched matcher until a match is found or all unmatched matchers are checked. Returns True (“matches”) on the final match.

Note

This is a stateful matcher. Once it has done its matching, you’ll need to create a new instance.

args_str()[source]

Return an args string for the repr.

match(item)[source]

Return True if the expected matchers are matched in any order, otherwise False.

to_matcher(matcher_factory, obj)[source]

Turn an object into a StreamMatcher unless it already is one.

Parameters:
  • matcher_factory – A callable capable of turning obj into a StreamMatcher.
  • obj – A StreamMatcher or an object to turn into one.
Returns:

StreamMatcher