diff --git a/requirements-dev.txt b/requirements-dev.txt index 70363e3..b633f3d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,6 @@ -asynctest flake8 pluggy>=0.12.0,<1.0.0 pytest pytest-asyncio~=0.21.0 python-dotenv -sphinx tox-travis \ No newline at end of file diff --git a/tests/test_async.py b/tests/test_async.py index ece42ea..fad05aa 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -1,27 +1,31 @@ import os +import unittest -import asynctest +import aiohttp import brawlstats import pytest + from dotenv import load_dotenv pytestmark = pytest.mark.asyncio load_dotenv() -class TestAsyncClient(asynctest.TestCase): +class TestAsyncClient(unittest.IsolatedAsyncioTestCase): PLAYER_TAG = '#V2LQY9UY' CLUB_TAG = '#UL0GCC8' - async def setUp(self): + async def asyncSetUp(self): + session = aiohttp.ClientSession(trust_env=True) self.client = brawlstats.Client( - os.getenv('token'), + token=os.getenv('token'), + session=session, base_url=os.getenv('base_url'), is_async=True ) - async def tearDown(self): + async def asyncTearDown(self): await self.client.close() async def test_get_player(self): @@ -72,7 +76,8 @@ async def test_get_club_members(self): self.assertIsInstance(club_members, brawlstats.Members) self.assertIn(self.PLAYER_TAG, [x.tag for x in club_members]) - await self.assertAsyncRaises(brawlstats.NotFoundError, self.client.get_club_members('8GGGGGGG')) + with self.assertRaises(brawlstats.NotFoundError): + await self.client.get_club_members('8GGGGGGG') async def test_get_rankings(self): player_ranking = await self.client.get_rankings(ranking='players') @@ -115,4 +120,4 @@ async def test_get_event_rotation(self): if __name__ == '__main__': - asynctest.main() + unittest.main() diff --git a/tests/test_blocking.py b/tests/test_blocking.py index cc3d0c8..76cb8f9 100644 --- a/tests/test_blocking.py +++ b/tests/test_blocking.py @@ -14,7 +14,7 @@ class TestBlockingClient(unittest.TestCase): def setUp(self): self.client = brawlstats.Client( - os.getenv('token'), + token=os.getenv('token'), base_url=os.getenv('base_url') )