code: def frozen_sleep(monkeypatch):
      """Use time-machine to "stub" sleep.
  
      This means the ``sleep()`` takes no time, but ``datetime.now()`` appears to move forwards.
  
      If your module under test does ``import time`` and then ``time.sleep``:
  
      .. code-block:: python
  
          def test_something(frozen_sleep):
              my_mod.fn_under_test()
  
      If your module under test does ``from time import sleep`` then you will
      have to mock that sleep function directly:
  
      .. code-block:: python
  
          def test_something(frozen_sleep, monkeypatch):
              monkeypatch.setattr("my_mod.sleep", frozen_sleep)
              my_mod.fn_under_test()
      """
      traveller = None
  
      def fake_sleep(seconds):
          nonlocal traveller
          utcnow = datetime.utcnow()
          if traveller is not None:
              traveller.stop()
          traveller = time_machine.travel(
              utcnow + timedelta(seconds=seconds)
          )
          traveller.start()
  
      monkeypatch.setattr("time.sleep", fake_sleep)
      yield fake_sleep
  
      if traveller is not None:
          traveller.stop()
  
imports: from __future__ import annotations
  import json
  import os
  import platform
  import subprocess
  import sys
  import warnings
  from contextlib import ExitStack, suppress
  from datetime import datetime, timedelta
  from pathlib import Path
  from typing import TYPE_CHECKING
  import pytest
  import time_machine
  from itsdangerous import URLSafeSerializer
label_desc: Use image node_id 25 for calling a global function with example usage: frozen_sleep(monkeypatch) without return types