I'm kind of a beginner with testing my code in Python, and I'm trying to test an API "wrapper" I created (working with Riot's API) with unittest.IsolatedAsyncioTestCase, and I have an error that says :
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002511047C160>
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002511047C160>
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Program Files\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Program Files\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
This error is after the test is finished since I have "Run 2 tests OK" just before.
Here is a simplified version of my code :
class TestMyMethods(unittest.IsolatedAsyncioTestCase):
def setUp(self):
"""Setting up the tests"""
# Loading dotenv
load_dotenv(dotenv_path=Path('.') / '.env')
# Initializing MyWrapper
self.mongo_client = MongoClient()
self.db = self.mongo_client["test-database"]
self.my_wrapper = MyWrapper(os.getenv("RIOT_API_KEY"), self.db)
async def test_get_summoner(self):
x = await self.grasp.grasp_summoner_data("SummonerName")
self.assertEqual(x["name"], "SummonerName")
if __name__ == '__main__':
with warnings.catch_warnings():
warnings.simplefilter("ignore")
unittest.main()
I can't find any clue of what's happening and what am I doing wrong, and there is not much documentation for this on the Internet.
Thanks for you help !