use asyncmock from unittest library

This commit is contained in:
2021-08-11 21:09:10 +03:00
parent 9c5a9f5837
commit b94179e071
2 changed files with 4 additions and 19 deletions

View File

@ -4,6 +4,7 @@ import pytest
from aiohttp.web_exceptions import HTTPBadRequest
from pytest_mock import MockerFixture
from typing import Any
from unittest.mock import AsyncMock
from ahriman.web.middlewares.exception_handler import exception_handler
@ -12,7 +13,7 @@ async def test_exception_handler(aiohttp_request: Any, mocker: MockerFixture) ->
"""
must pass success response
"""
request_handler = pytest.helpers.AsyncMock()
request_handler = AsyncMock()
logging_mock = mocker.patch("logging.Logger.exception")
handler = exception_handler(logging.getLogger())
@ -24,7 +25,7 @@ async def test_exception_handler_client_error(aiohttp_request: Any, mocker: Mock
"""
must pass client exception
"""
request_handler = pytest.helpers.AsyncMock()
request_handler = AsyncMock()
request_handler.side_effect = HTTPBadRequest()
logging_mock = mocker.patch("logging.Logger.exception")
@ -38,7 +39,7 @@ async def test_exception_handler_server_error(aiohttp_request: Any, mocker: Mock
"""
must log server exception and re-raise it
"""
request_handler = pytest.helpers.AsyncMock()
request_handler = AsyncMock()
request_handler.side_effect = Exception()
logging_mock = mocker.patch("logging.Logger.exception")