Allow mocking usage of timers in the test suite
This commit is contained in:
parent
40786427b0
commit
87f6793552
1 changed files with 7 additions and 1 deletions
|
|
@ -351,9 +351,12 @@ def __init__(self, window_id: int):
|
|||
self.pending_receive_responses: Deque[Tuple[str, str]] = deque()
|
||||
self.pending_timer: Optional[int] = None
|
||||
|
||||
def callback_after(self, callback: Callable[[Optional[int]], None], timeout: float) -> Optional[int]:
|
||||
return add_timer(callback, timeout, False)
|
||||
|
||||
def start_pending_timer(self) -> None:
|
||||
if self.pending_timer is None:
|
||||
self.pending_timer = add_timer(self.try_pending, 0.2, False)
|
||||
self.pending_timer = self.callback_after(self.try_pending, 0.2)
|
||||
|
||||
def try_pending(self, timer_id: Optional[int]) -> None:
|
||||
self.pending_timer = None
|
||||
|
|
@ -536,3 +539,6 @@ def write_osc_to_child(self, request_id: str, payload: str, appendleft: bool = F
|
|||
|
||||
def start_receive(self, aid: str) -> None:
|
||||
self.handle_send_confirmation(aid, {'response': 'y' if self.allow else 'n'})
|
||||
|
||||
def callback_after(self, callback: Callable[[Optional[int]], None], timeout: float) -> Optional[int]:
|
||||
callback(None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue