Silence 2to3 warnings in packaging tests
diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
index 8394f54..c6e3f72 100644
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -28,13 +28,11 @@
"""
import os
-import errno
import shutil
import logging
import weakref
import tempfile
-from packaging import logger
from packaging.dist import Distribution
from packaging.tests import unittest
from test.support import requires_zlib, unlink
@@ -44,6 +42,10 @@
'skip_unless_symlink', 'requires_zlib']
+logger = logging.getLogger('packaging')
+logger2to3 = logging.getLogger('RefactoringTool')
+
+
class _TestHandler(logging.handlers.BufferingHandler):
# stolen and adapted from test.support
@@ -74,9 +76,10 @@
def setUp(self):
super(LoggingCatcher, self).setUp()
self.loghandler = handler = _TestHandler()
- self.old_level = logger.level
+ self._old_levels = logger.level, logger2to3.level
logger.addHandler(handler)
logger.setLevel(logging.DEBUG) # we want all messages
+ logger2to3.setLevel(logging.CRITICAL) # we don't want 2to3 messages
def tearDown(self):
handler = self.loghandler
@@ -87,7 +90,8 @@
for ref in weakref.getweakrefs(handler):
logging._removeHandlerRef(ref)
del self.loghandler
- logger.setLevel(self.old_level)
+ logger.setLevel(self._old_levels[0])
+ logger2to3.setLevel(self._old_levels[1])
super(LoggingCatcher, self).tearDown()
def get_logs(self, *levels):