File: test_compat.py

package info (click to toggle)
litestar 2.21.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,568 kB
  • sloc: python: 70,588; makefile: 254; javascript: 104; sh: 60
file content (17 lines) | stat: -rw-r--r-- 378 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from typing import AsyncGenerator

import pytest

from litestar.utils.compat import async_next


async def test_async_next() -> None:
    async def generator() -> AsyncGenerator:
        yield 1

    gen = generator()

    assert await async_next(gen) == 1
    assert await async_next(gen, None) is None
    with pytest.raises(StopAsyncIteration):
        await async_next(gen)