async def test_nested_move_on_after() -> None: sleep_completed = inner_scope_completed = False with move_on_after(0.1) as outer_scope: assert current_effective_deadline() == outer_scope.deadline with move_on_after(1) as inner_scope: assert current_effective_deadline() == outer_scope.deadline await sleep(2) sleep_completed = True inner_scope_completed = True assert not sleep_completed assert not inner_scope_completed assert outer_scope.cancel_called assert not inner_scope.cancel_called
async def test_current_effective_deadline(self) -> None: value = await maybe_async(current_effective_deadline()) assert type(value) is float
async def test_shielded_deadline() -> None: with move_on_after(10): with CancelScope(shield=True): with move_on_after(1000): assert current_effective_deadline() - current_time() > 900