summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-14 20:26:34 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-14 20:26:34 (GMT)
commit1cae9ec96667e80e85fcdb034206dfd614708cd1 (patch)
treec99c3b09396a7aedd4cf6f0c67e6f916c569fab3 /Lib/asyncio
parentacdb782a83d72a823030335e8f190890ae4df9cf (diff)
downloadcpython-1cae9ec96667e80e85fcdb034206dfd614708cd1.zip
cpython-1cae9ec96667e80e85fcdb034206dfd614708cd1.tar.gz
cpython-1cae9ec96667e80e85fcdb034206dfd614708cd1.tar.bz2
asyncio tests: make quiet the logs of SSL handshake failures when running tests
in debug mode
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/test_utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/asyncio/test_utils.py b/Lib/asyncio/test_utils.py
index 6abcaf1..840bbf9 100644
--- a/Lib/asyncio/test_utils.py
+++ b/Lib/asyncio/test_utils.py
@@ -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)