Skip to content

Commit

Permalink
Remove use of IsolatedAsyncioTestCase.
Browse files Browse the repository at this point in the history
It's not available in all versions of Python we support.
  • Loading branch information
Bryan Worrell committed Feb 18, 2021
1 parent a63a35b commit b1b1f80
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/contacts/test_contact_tcp.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import logging
import socket
from unittest import mock
from unittest import IsolatedAsyncioTestCase

from app.contacts.contact_tcp import TcpSessionHandler

logger = logging.getLogger(__name__)


class TestTcpSessionHandler(IsolatedAsyncioTestCase):
class TestTcpSessionHandler:

async def test_refresh_with_socket_errors(self):
def test_refresh_with_socket_errors(self, loop):
handler = TcpSessionHandler(services=None, log=logger)

session_with_socket_error = mock.Mock()
Expand All @@ -22,17 +21,17 @@ async def test_refresh_with_socket_errors(self):
mock.Mock()
]

await handler.refresh()
loop.run_until_complete(handler.refresh())
assert len(handler.sessions) == 1
assert all(x is not session_with_socket_error for x in handler.sessions)

async def test_refresh_without_socket_errors(self):
def test_refresh_without_socket_errors(self, loop):
handler = TcpSessionHandler(services=None, log=logger)
handler.sessions = [
mock.Mock(),
mock.Mock(),
mock.Mock()
]

await handler.refresh()
loop.run_until_complete(handler.refresh())
assert len(handler.sessions) == 3

0 comments on commit b1b1f80

Please sign in to comment.