Skip to content

Commit b83bc11

Browse files
committed
fix: wait_for_logs
1 parent 5064794 commit b83bc11

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/testcontainers/core/waiting_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import re
1616
import time
1717
import traceback
18-
from typing import TYPE_CHECKING, Any, Callable, Union, cast
18+
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
1919

2020
import wrapt
2121

@@ -104,8 +104,14 @@ def wait_for_logs(
104104
Returns:
105105
duration: Number of seconds until the predicate was satisfied.
106106
"""
107+
re_predicate: Optional[Callable[[str], Any]] = None
107108
if isinstance(predicate, str):
108109
re_predicate = re.compile(predicate, re.MULTILINE).search
110+
elif callable(predicate):
111+
# some modules like mysql sends the search directly to the predicate
112+
re_predicate = predicate
113+
else:
114+
raise TypeError("Predicate must be a string or callable")
109115
wrapped = container.get_wrapped_container()
110116
start = time.time()
111117
while True:

0 commit comments

Comments
 (0)