nixos/test-driver: add wait_before_entry to polling_condition
This commit is contained in:
parent
57beeedbdf
commit
1db0dcdfec
1 changed files with 8 additions and 0 deletions
|
@ -202,6 +202,7 @@ class Driver:
|
|||
*,
|
||||
seconds_interval: float = 2.0,
|
||||
description: Optional[str] = None,
|
||||
wait_before_entry: bool = False,
|
||||
) -> Union[Callable[[Callable], ContextManager], ContextManager]:
|
||||
driver = self
|
||||
|
||||
|
@ -212,8 +213,15 @@ class Driver:
|
|||
seconds_interval,
|
||||
description,
|
||||
)
|
||||
self.wait_before_entry = wait_before_entry
|
||||
|
||||
def __enter__(self) -> None:
|
||||
if self.wait_before_entry:
|
||||
with rootlog.nested(
|
||||
f"waiting before entering polling condition {self.condition.description}"
|
||||
):
|
||||
retry(lambda x: self.condition.check(force=True))
|
||||
|
||||
driver.polling_conditions.append(self.condition)
|
||||
|
||||
def __exit__(self, a, b, c) -> None: # type: ignore
|
||||
|
|
Loading…
Reference in a new issue