From 247fb5a6d498f54291d557fbf51ccd3025e7f83a Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 25 Sep 2021 16:48:33 +0200 Subject: [PATCH] Proper cleanup after tests --- test/conftest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/conftest.py b/test/conftest.py index 78725ff..65744e7 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -1,3 +1,4 @@ +import asyncio import sys from pathlib import Path from unittest.mock import Mock @@ -23,8 +24,17 @@ def bot(mocker: MockerFixture): def mbot(bot): mbot_mock = Music(bot) yield mbot_mock + mbot_mock.cog_unload() @pytest.fixture def ctx(mocker: MockerFixture): yield mocker.patch('discord.ext.commands.Context', autospec=True) + + +@pytest.fixture +def event_loop(): + loop = asyncio.get_event_loop() + yield loop + pending = asyncio.all_tasks(loop=loop) + asyncio.ensure_future(asyncio.gather(*pending))