Skip to content

test: replace aiounittest by IsolatedAsyncioTestCase #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ Sphinx>=1.8.0
mock
pytest
pytest-cov
aiounittest
flake8
wheel>=0.22.0
cryptography
9 changes: 4 additions & 5 deletions tests/unit/http/test_async_http_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import aiounittest

import unittest
from aiohttp import ClientSession
from mock import patch, AsyncMock
from twilio.http.async_http_client import AsyncTwilioHttpClient
@@ -19,7 +18,7 @@ async def text(self):
return self._text


class TestAsyncHttpClientRequest(aiounittest.AsyncTestCase):
class TestAsyncHttpClientRequest(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.session_mock = AsyncMock(wraps=ClientSession)
self.session_mock.request.return_value = MockResponse("test", 200)
@@ -58,7 +57,7 @@ async def test_invalid_request_timeout_raises_exception(self):
await self.client.request("doesnt matter", "doesnt matter", timeout=-1)


class TestAsyncHttpClientRetries(aiounittest.AsyncTestCase):
class TestAsyncHttpClientRetries(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.session_mock = AsyncMock(wraps=ClientSession)
self.session_mock.request.side_effect = [
@@ -91,7 +90,7 @@ async def test_request_retries_until_max(self):
self.assertEqual(response.text, "Error")


class TestAsyncHttpClientSession(aiounittest.AsyncTestCase):
class TestAsyncHttpClientSession(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.session_patcher = patch("twilio.http.async_http_client.ClientSession")
self.session_constructor_mock = self.session_patcher.start()
3 changes: 1 addition & 2 deletions tests/unit/rest/test_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import aiounittest

from mock import AsyncMock, Mock
from twilio.http.response import Response
@@ -106,7 +105,7 @@ def test_set_user_agent_extensions(self):
self.assertEqual(user_agent_extensions, expected_user_agent_extensions)


class TestClientAsyncRequest(aiounittest.AsyncTestCase):
class TestClientAsyncRequest(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.mock_async_http_client = AsyncMock()
self.mock_async_http_client.request.return_value = Response(200, "test")