From a5b8099a7b4da288058d852a8f303a46154fb6bc Mon Sep 17 00:00:00 2001 From: wookie184 Date: Sun, 9 Jul 2023 09:44:30 +0100 Subject: Fix some test warnings (#2675) * Fix test warnings * Remove unnecessary event_loop parameters This is not necessary as the current event loop will be used which is the same as self.bot.loop. Removing these should slightly improve test speed as the mock for self.bot.loop doesn't need to be created. --- tests/helpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/helpers.py') diff --git a/tests/helpers.py b/tests/helpers.py index 26ac42697..580848c25 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -6,6 +6,7 @@ import logging import unittest.mock from asyncio import AbstractEventLoop from collections.abc import Iterable +from contextlib import contextmanager from functools import cached_property import discord @@ -664,3 +665,12 @@ class MockAsyncWebhook(CustomMockMixin, unittest.mock.MagicMock): """ spec_set = webhook_instance additional_spec_asyncs = ("send", "edit", "delete", "execute") + +@contextmanager +def no_create_task(): + def side_effect(coro, *_, **__): + coro.close() + + with unittest.mock.patch("pydis_core.utils.scheduling.create_task") as create_task: + create_task.side_effect = side_effect + yield -- cgit v1.2.3