at 25.11-pre 1.7 kB view raw
1# This file contains type hints that can be prepended to Nix test scripts so they can be type 2# checked. 3 4from test_driver.driver import Driver 5from test_driver.vlan import VLan 6from test_driver.machine import Machine 7from test_driver.logger import AbstractLogger 8from typing import Callable, Iterator, ContextManager, Optional, List, Dict, Any, Union 9from typing_extensions import Protocol 10from pathlib import Path 11from unittest import TestCase 12 13 14class RetryProtocol(Protocol): 15 def __call__(self, fn: Callable, timeout: int = 900) -> None: 16 raise Exception("This is just type information for the Nix test driver") 17 18 19class PollingConditionProtocol(Protocol): 20 def __call__( 21 self, 22 fun_: Optional[Callable] = None, 23 *, 24 seconds_interval: float = 2.0, 25 description: Optional[str] = None, 26 ) -> Union[Callable[[Callable], ContextManager], ContextManager]: 27 raise Exception("This is just type information for the Nix test driver") 28 29 30class CreateMachineProtocol(Protocol): 31 def __call__( 32 self, 33 start_command: str | dict, 34 *, 35 name: Optional[str] = None, 36 keep_vm_state: bool = False, 37 ) -> Machine: 38 raise Exception("This is just type information for the Nix test driver") 39 40 41start_all: Callable[[], None] 42subtest: Callable[[str], ContextManager[None]] 43retry: RetryProtocol 44test_script: Callable[[], None] 45machines: List[Machine] 46vlans: List[VLan] 47driver: Driver 48log: AbstractLogger 49create_machine: CreateMachineProtocol 50run_tests: Callable[[], None] 51join_all: Callable[[], None] 52serial_stdout_off: Callable[[], None] 53serial_stdout_on: Callable[[], None] 54polling_condition: PollingConditionProtocol 55t: TestCase