nixos/test-driver: add wait_before_entry to polling_condition
This commit is contained in:
parent
57beeedbdf
commit
1db0dcdfec
|
@ -202,6 +202,7 @@ class Driver:
|
||||||
*,
|
*,
|
||||||
seconds_interval: float = 2.0,
|
seconds_interval: float = 2.0,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
|
wait_before_entry: bool = False,
|
||||||
) -> Union[Callable[[Callable], ContextManager], ContextManager]:
|
) -> Union[Callable[[Callable], ContextManager], ContextManager]:
|
||||||
driver = self
|
driver = self
|
||||||
|
|
||||||
|
@ -212,8 +213,15 @@ class Driver:
|
||||||
seconds_interval,
|
seconds_interval,
|
||||||
description,
|
description,
|
||||||
)
|
)
|
||||||
|
self.wait_before_entry = wait_before_entry
|
||||||
|
|
||||||
def __enter__(self) -> None:
|
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)
|
driver.polling_conditions.append(self.condition)
|
||||||
|
|
||||||
def __exit__(self, a, b, c) -> None: # type: ignore
|
def __exit__(self, a, b, c) -> None: # type: ignore
|
||||||
|
|
Loading…
Reference in a new issue