1 # This file contains type hints that can be prepended to Nix test scripts so they can be type
4 from test_driver
.driver
import Driver
5 from test_driver
.vlan
import VLan
6 from test_driver
.machine
import Machine
7 from test_driver
.logger
import AbstractLogger
8 from typing
import Callable
, Iterator
, ContextManager
, Optional
, List
, Dict
, Any
, Union
9 from typing_extensions
import Protocol
10 from pathlib
import Path
13 class RetryProtocol(Protocol
):
14 def __call__(self
, fn
: Callable
, timeout
: int = 900) -> None:
15 raise Exception("This is just type information for the Nix test driver")
18 class PollingConditionProtocol(Protocol
):
21 fun_
: Optional
[Callable
] = None,
23 seconds_interval
: float = 2.0,
24 description
: Optional
[str] = None,
25 ) -> Union
[Callable
[[Callable
], ContextManager
], ContextManager
]:
26 raise Exception("This is just type information for the Nix test driver")
29 class CreateMachineProtocol(Protocol
):
32 start_command
: str |
dict,
34 name
: Optional
[str] = None,
35 keep_vm_state
: bool = False,
37 raise Exception("This is just type information for the Nix test driver")
40 start_all
: Callable
[[], None]
41 subtest
: Callable
[[str], ContextManager
[None]]
43 test_script
: Callable
[[], None]
44 machines
: List
[Machine
]
48 create_machine
: CreateMachineProtocol
49 run_tests
: Callable
[[], None]
50 join_all
: Callable
[[], None]
51 serial_stdout_off
: Callable
[[], None]
52 serial_stdout_on
: Callable
[[], None]
53 polling_condition
: PollingConditionProtocol