mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Use AsyncMock with python 3.8 instead of asynctest
This commit is contained in:
parent
6f56f24296
commit
8e5cb067df
8 changed files with 123 additions and 105 deletions
|
|
@ -1,12 +1,14 @@
|
|||
import copy
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
||||
from aiogram.api.client.base import BaseBot
|
||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.api.methods import GetMe
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch
|
||||
|
||||
|
||||
class TestBaseBot:
|
||||
def test_init(self):
|
||||
|
|
|
|||
|
|
@ -4,12 +4,16 @@ from typing import AsyncContextManager
|
|||
import aiohttp
|
||||
import pytest
|
||||
from aresponses import ResponsesMockServer
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.api.methods import Request, TelegramMethod
|
||||
from aiogram.api.types import InputFile
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch
|
||||
|
||||
|
||||
class BareInputFile(InputFile):
|
||||
async def read(self, chunk_size: int):
|
||||
|
|
|
|||
|
|
@ -2,13 +2,17 @@ import datetime
|
|||
from typing import AsyncContextManager
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
||||
from aiogram.api.client.session.base import BaseSession, T
|
||||
from aiogram.api.client.telegram import PRODUCTION, TelegramAPIServer
|
||||
from aiogram.api.methods import GetMe, Response, TelegramMethod
|
||||
from aiogram.utils.mixins import DataMixin
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch
|
||||
|
||||
|
||||
class CustomSession(BaseSession):
|
||||
async def close(self):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import datetime
|
|||
import time
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.api.methods import GetMe, GetUpdates, SendMessage
|
||||
|
|
@ -11,6 +10,11 @@ from aiogram.dispatcher.dispatcher import Dispatcher
|
|||
from aiogram.dispatcher.router import Router
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch
|
||||
|
||||
|
||||
class TestDispatcher:
|
||||
def test_parent_router(self):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
from typing import Awaitable
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
from aiogram.dispatcher.filters.base import BaseFilter
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch
|
||||
|
||||
|
||||
class MyFilter(BaseFilter):
|
||||
foo: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue