Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide convenience function to SearcherCollection #2

Open
nastevens opened this issue Jan 21, 2016 · 0 comments
Open

Provide convenience function to SearcherCollection #2

nastevens opened this issue Jan 21, 2016 · 0 comments

Comments

@nastevens
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant