Skip to content

Provide convenience function to SearcherCollection #2

@nastevens

Description

@nastevens

Right now accessing SearcherCollection to expect on a list of multiple patterns is clunky:

pat1 = RegexSearcher('pattern 1')
pat2 = RegexSearcher('pattern 2')
search = SearcherCollection([pat1, pat2])
with streamexpect.wrap(buf) as stream:
    match = stream.expect(search)
if match.searcher is pat1:
    # do stuff
else:
    pass

Instead, the expect_regex and expect_text functions could be extended to automatically add a SearcherCollection when they are passed a collection (list, tuple, etc):

pat1 = 'pattern 1'
pat2 = 'pattern 2'
with streamexpect.wrap(buf) as stream:
    match = stream.expect_regex([pat1, pat2])
if match.searcher is pat1:
    # do stuff
else:
    pass

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions