1 # SPDX-License-Identifier: GPL-3.0-or-later
 
   3 # This file is part of Nominatim. (https://nominatim.org)
 
   5 # Copyright (C) 2025 by the Nominatim developer community.
 
   6 # For a full list of authors see the git log.
 
   8 Tests for timeout helper
 
  14 from nominatim_api.timeout import Timeout
 
  18 async def test_timeout_none():
 
  19     timeout = Timeout(None)
 
  21     assert timeout.abs is None
 
  22     assert not timeout.is_elapsed()
 
  26 async def test_timeout_should_not_be_elapsed_after_creation():
 
  27     assert not Timeout(2).is_elapsed()
 
  31 async def test_timeout_elapse():
 
  32     timeout = Timeout(0.5)
 
  34     assert timeout.abs is not None
 
  35     await asyncio.sleep(0.5)
 
  36     assert timeout.is_elapsed()