From 236c3e83722a36eddb4abb111a2fcceb49cc9ab7 Mon Sep 17 00:00:00 2001 From: summersamara Date: Wed, 3 Jul 2024 15:00:12 +0200 Subject: [PATCH] Add optional ignore_case param to wait_for_strings --- src/process_tests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/process_tests.py b/src/process_tests.py index 81ea5cd..9cddd03 100644 --- a/src/process_tests.py +++ b/src/process_tests.py @@ -223,7 +223,7 @@ def __exit__(self, exc_type=None, exc_value=None, exc_traceback=None): close = __exit__ -def wait_for_strings(cb, seconds, *strings): +def wait_for_strings(cb, seconds, *strings, ignore_case=False): """ This checks that *string appear in cb(), IN THE GIVEN ORDER ! """ @@ -232,7 +232,11 @@ def wait_for_strings(cb, seconds, *strings): buff = cb() check_strings = list(strings) check_strings.reverse() + if ignore_case: + check_strings = [string.casefold() for string in check_strings] for line in buff.splitlines(): + if ignore_case: + line = line.casefold() if not check_strings: break while check_strings and check_strings[-1] in line: