Proper cleanup after tests

This commit is contained in:
ekzyis 2021-09-25 16:48:33 +02:00
parent ac6b8783ba
commit 247fb5a6d4
1 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import asyncio
import sys import sys
from pathlib import Path from pathlib import Path
from unittest.mock import Mock from unittest.mock import Mock
@ -23,8 +24,17 @@ def bot(mocker: MockerFixture):
def mbot(bot): def mbot(bot):
mbot_mock = Music(bot) mbot_mock = Music(bot)
yield mbot_mock yield mbot_mock
mbot_mock.cog_unload()
@pytest.fixture @pytest.fixture
def ctx(mocker: MockerFixture): def ctx(mocker: MockerFixture):
yield mocker.patch('discord.ext.commands.Context', autospec=True) 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))