|
1 | 1 | import os |
| 2 | +import unittest |
2 | 3 |
|
3 | | -import asynctest |
| 4 | +import aiohttp |
4 | 5 | import brawlstats |
5 | 6 | import pytest |
| 7 | + |
6 | 8 | from dotenv import load_dotenv |
7 | 9 |
|
8 | 10 | pytestmark = pytest.mark.asyncio |
9 | 11 | load_dotenv() |
10 | 12 |
|
11 | 13 |
|
12 | | -class TestAsyncClient(asynctest.TestCase): |
| 14 | +class TestAsyncClient(unittest.IsolatedAsyncioTestCase): |
13 | 15 |
|
14 | 16 | PLAYER_TAG = '#V2LQY9UY' |
15 | 17 | CLUB_TAG = '#UL0GCC8' |
16 | 18 |
|
17 | | - async def setUp(self): |
| 19 | + async def asyncSetUp(self): |
| 20 | + session = aiohttp.ClientSession(trust_env=True) |
18 | 21 | self.client = brawlstats.Client( |
19 | | - os.getenv('token'), |
| 22 | + token=os.getenv('token'), |
| 23 | + session=session, |
20 | 24 | base_url=os.getenv('base_url'), |
21 | 25 | is_async=True |
22 | 26 | ) |
23 | 27 |
|
24 | | - async def tearDown(self): |
| 28 | + async def asyncTearDown(self): |
25 | 29 | await self.client.close() |
26 | 30 |
|
27 | 31 | async def test_get_player(self): |
@@ -72,7 +76,8 @@ async def test_get_club_members(self): |
72 | 76 | self.assertIsInstance(club_members, brawlstats.Members) |
73 | 77 | self.assertIn(self.PLAYER_TAG, [x.tag for x in club_members]) |
74 | 78 |
|
75 | | - await self.assertAsyncRaises(brawlstats.NotFoundError, self.client.get_club_members('8GGGGGGG')) |
| 79 | + with self.assertRaises(brawlstats.NotFoundError): |
| 80 | + await self.client.get_club_members('8GGGGGGG') |
76 | 81 |
|
77 | 82 | async def test_get_rankings(self): |
78 | 83 | player_ranking = await self.client.get_rankings(ranking='players') |
@@ -115,4 +120,4 @@ async def test_get_event_rotation(self): |
115 | 120 |
|
116 | 121 |
|
117 | 122 | if __name__ == '__main__': |
118 | | - asynctest.main() |
| 123 | + unittest.main() |
0 commit comments