Skip to content

Commit

Permalink
Properly tearDown in async tests and match ordering in blocking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpBit committed Oct 6, 2024
1 parent 54f76c0 commit b51e29d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
13 changes: 4 additions & 9 deletions tests/test_async.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import aiohttp
import asynctest
import brawlstats
import pytest
Expand All @@ -11,21 +10,20 @@


class TestAsyncClient(asynctest.TestCase):
use_default_loop = True

PLAYER_TAG = '#V2LQY9UY'
CLUB_TAG = '#UL0GCC8'

async def setUp(self):
session = aiohttp.ClientSession(loop=self.loop)

self.client = brawlstats.Client(
os.getenv('token'),
base_url=os.getenv('base_url'),
is_async=True,
session=session
is_async=True
)

async def tearDown(self):
await self.client.close()

async def test_get_player(self):
player = await self.client.get_player(self.PLAYER_TAG)
self.assertIsInstance(player, brawlstats.Player)
Expand Down Expand Up @@ -117,9 +115,6 @@ async def test_get_brawlers(self):
brawlers = await self.client.get_brawlers()
self.assertIsInstance(brawlers, brawlstats.Brawlers)

async def asyncTearDown(self):
await self.client.close()


if __name__ == '__main__':
asynctest.main()
7 changes: 3 additions & 4 deletions tests/test_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class TestBlockingClient(unittest.TestCase):
CLUB_TAG = '#UL0GCC8'

def setUp(self):

self.client = brawlstats.Client(
os.getenv('token'),
base_url=os.getenv('base_url')
)

def tearDown(self):
self.client.close()

def test_get_player(self):
player = self.client.get_player(self.PLAYER_TAG)
self.assertIsInstance(player, brawlstats.Player)
Expand Down Expand Up @@ -95,9 +97,6 @@ def test_get_brawlers(self):
brawlers = self.client.get_brawlers()
self.assertIsInstance(brawlers, brawlstats.Brawlers)

def tearDown(self):
self.client.close()


if __name__ == '__main__':
unittest.main()

0 comments on commit b51e29d

Please sign in to comment.