/
kajumz
/
python_async
Обзор
Документация
Войти
/
kajumz
/
python_async
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
homework/tests/test_task_1.py
35 строк
821 B
kajumz
Initial commit
25 дек 2024, 22:25
Не верифицирован
25 дек 2024, 22:25
43242a1
Код
Авторство
О чём код?
import asyncio import random from unittest.mock import AsyncMock import pytest from homework.tasks.task_1 import await_my_func @pytest.mark.asyncio async def test_await_my_func_callable(): m = AsyncMock(return_value=random.random()) assert await await_my_func(m) == m.return_value m.assert_called_once() m.assert_awaited_once() @pytest.mark.asyncio async def test_await_my_func_coroutine(): m = AsyncMock(return_value=random.random()) assert await await_my_func(m()) == m.return_value m.assert_called_once() m.assert_awaited_once() @pytest.mark.asyncio async def test_await_my_func_task(): m = AsyncMock(return_value=random.random()) t = asyncio.create_task(m()) assert await await_my_func(t) == m.return_value m.assert_called_once() m.assert_awaited_once()