mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
asyncio tests: make quiet the logs of SSL handshake failures when running tests
in debug mode
This commit is contained in:
parent
acdb782a83
commit
1cae9ec966
3 changed files with 37 additions and 17 deletions
|
@ -3,6 +3,7 @@
|
|||
import collections
|
||||
import contextlib
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
|
@ -28,6 +29,7 @@ from . import futures
|
|||
from . import selectors
|
||||
from . import tasks
|
||||
from .coroutines import coroutine
|
||||
from .log import logger
|
||||
|
||||
|
||||
if sys.platform == 'win32': # pragma: no cover
|
||||
|
@ -401,3 +403,17 @@ class TestCase(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
events.set_event_loop(None)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def disable_logger():
|
||||
"""Context manager to disable asyncio logger.
|
||||
|
||||
For example, it can be used to ignore warnings in debug mode.
|
||||
"""
|
||||
old_level = logger.level
|
||||
try:
|
||||
logger.setLevel(logging.CRITICAL+1)
|
||||
yield
|
||||
finally:
|
||||
logger.setLevel(old_level)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue