aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-10-15 11:45:38 +0200
committerGravatar GitHub <[email protected]>2021-10-15 09:56:17 +0000
commit76357945114315063312a13f8e272dcc78d5400d (patch)
tree83190e69c6c98ae2b79e40445b8e419fcaf2dceb /tests
parentVoice gate: set tzinfo to None in author.joined_at (diff)
parentMerge pull request #1874 from python-discord/fix-bot-1869 (diff)
Merge branch 'main' into discord-2.0
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py3
-rw-r--r--tests/base.py3
-rw-r--r--tests/bot/exts/backend/sync/test_base.py1
-rw-r--r--tests/test_base.py11
4 files changed, 9 insertions, 9 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 2228110ad..c2b9d12dc 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,6 @@
import logging
+from bot.log import get_logger
-log = logging.getLogger()
+log = get_logger()
log.setLevel(logging.CRITICAL)
diff --git a/tests/base.py b/tests/base.py
index 79ff5bc7e..5e304ea9d 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -6,6 +6,7 @@ from typing import Dict
import discord
from discord.ext import commands
+from bot.log import get_logger
from tests import helpers
@@ -42,7 +43,7 @@ class LoggingTestsMixin:
manager when we're testing under the assumption that no log records will be emitted.
"""
if not isinstance(logger, logging.Logger):
- logger = logging.getLogger(logger)
+ logger = get_logger(logger)
if level:
level = logging._nameToLevel.get(level, level)
diff --git a/tests/bot/exts/backend/sync/test_base.py b/tests/bot/exts/backend/sync/test_base.py
index 3ad9db9c3..9dc46005b 100644
--- a/tests/bot/exts/backend/sync/test_base.py
+++ b/tests/bot/exts/backend/sync/test_base.py
@@ -1,7 +1,6 @@
import unittest
from unittest import mock
-
from bot.api import ResponseCodeError
from bot.exts.backend.sync._syncers import Syncer
from tests import helpers
diff --git a/tests/test_base.py b/tests/test_base.py
index a7db4bf3e..365805a71 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -1,8 +1,7 @@
import logging
-import unittest
import unittest.mock
-
+from bot.log import get_logger
from tests.base import LoggingTestsMixin, _CaptureLogHandler
@@ -15,7 +14,7 @@ class LoggingTestCaseTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
- cls.log = logging.getLogger(__name__)
+ cls.log = get_logger(__name__)
def test_assert_not_logs_does_not_raise_with_no_logs(self):
"""Test if LoggingTestCase.assertNotLogs does not raise when no logs were emitted."""
@@ -56,15 +55,15 @@ class LoggingTestCaseTests(unittest.TestCase):
def test_logging_test_case_works_with_logger_instance(self):
"""Test if the LoggingTestCase captures logging for provided logger."""
- log = logging.getLogger("new_logger")
+ log = get_logger("new_logger")
with self.assertRaises(AssertionError):
with LoggingTestCase.assertNotLogs(self, logger=log):
log.info("Hello, this should raise an AssertionError")
def test_logging_test_case_respects_alternative_logger(self):
"""Test if LoggingTestCase only checks the provided logger."""
- log_one = logging.getLogger("log one")
- log_two = logging.getLogger("log two")
+ log_one = get_logger("log one")
+ log_two = get_logger("log two")
with LoggingTestCase.assertNotLogs(self, logger=log_one):
log_two.info("Hello, this should not raise an AssertionError")