1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
# SPDX-FileCopyrightText: Christian Amsüss and the aiocoap contributors
#
# SPDX-License-Identifier: MIT
import asyncio
from aiocoap.util.asyncio.timeoutdict import TimeoutDict
from .fixtures import WithAsyncLoop, asynctest
class TestTimeoutDict(WithAsyncLoop):
@asynctest
async def test_presence_and_absence(self):
timeout = 0.2
d = TimeoutDict(timeout)
d["k"] = "v"
await asyncio.sleep(timeout / 2)
assert d["k"] == "v"
await asyncio.sleep(timeout * 2.5)
self.assertRaises(KeyError, lambda: d["k"])
|