Esempio n. 1
0
async def test_mix_zone_timeout_freeze():
    """Test a mix zone timeout global freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2, "test"):
        async with timeout.async_freeze():
            await asyncio.sleep(0.3)
Esempio n. 2
0
async def test_simple_global_timeout_freeze():
    """Test a simple global timeout freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2):
        async with timeout.async_freeze():
            await asyncio.sleep(0.3)
Esempio n. 3
0
async def test_simple_zone_timeout_freeze_without_timeout():
    """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.1, "test"):
        async with timeout.async_freeze("test"):
            await asyncio.sleep(0.3)
Esempio n. 4
0
async def test_simple_zone_timeout_freeze():
    """Test a simple zone timeout freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2, "test"):
        async with timeout.async_freeze("test"):
            await asyncio.sleep(0.3)
Esempio n. 5
0
async def test_simple_global_timeout_freeze_with_executor_job(hass):
    """Test a simple global timeout freeze with executor job."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2):
        async with timeout.async_freeze():
            await hass.async_add_executor_job(lambda: time.sleep(0.3))
Esempio n. 6
0
async def test_simple_zone_timeout_freeze_reset():
    """Test a simple zone timeout freeze reset."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.2, "test"):
            async with timeout.async_freeze("test"):
                await asyncio.sleep(0.1)
            await asyncio.sleep(0.2, "test")
Esempio n. 7
0
async def test_simple_global_timeout_freeze_reset():
    """Test a simple global timeout freeze reset."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.2):
            async with timeout.async_freeze():
                await asyncio.sleep(0.1)
            await asyncio.sleep(0.2)
Esempio n. 8
0
async def test_simple_zone_timeout_freeze_without_timeout_exeption():
    """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.1):
            with suppress(RuntimeError):
                async with timeout.async_freeze("test"):
                    raise RuntimeError()

            await asyncio.sleep(0.4)