]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95573: Fix a mistake in asyncio ssl tests suppressing all logs (GH-95687) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 5 Aug 2022 08:07:15 +0000 (01:07 -0700)
committerGitHub <noreply@github.com>
Fri, 5 Aug 2022 08:07:15 +0000 (10:07 +0200)
(cherry picked from commit e1d68b3ce71de76b3d7e5852e9bdfdbb4efea2f8)

Co-authored-by: Fantix King <fantix.king@gmail.com>
Lib/test/test_asyncio/test_ssl.py

index 5e3c1573c9c587122c986100caf54bcb1c7f339a..a2b5f8d258cd0015eaa90315158528344905d94b 100644 (file)
@@ -58,6 +58,16 @@ class MyBaseProto(asyncio.Protocol):
             self.done.set_result(None)
 
 
+class MessageOutFilter(logging.Filter):
+    def __init__(self, msg):
+        self.msg = msg
+
+    def filter(self, record):
+        if self.msg in record.msg:
+            return False
+        return True
+
+
 @unittest.skipIf(ssl is None, 'No ssl module')
 class TestSSL(test_utils.TestCase):
 
@@ -149,7 +159,7 @@ class TestSSL(test_utils.TestCase):
     def _silence_eof_received_warning(self):
         # TODO This warning has to be fixed in asyncio.
         logger = logging.getLogger('asyncio')
-        filter = logging.Filter('has no effect when using ssl')
+        filter = MessageOutFilter('has no effect when using ssl')
         logger.addFilter(filter)
         try:
             yield