summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/support.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-07-15 15:49:20 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-07-15 15:49:20 (GMT)
commiteb39294101ba45c154d7221e970f65e30067574e (patch)
tree278aa35f15d9ff606348d2b7daec1f6ed3139321 /Lib/packaging/tests/support.py
parentdccf9855fcfde49f53dd454c83115d0aacc71e71 (diff)
downloadcpython-eb39294101ba45c154d7221e970f65e30067574e.zip
cpython-eb39294101ba45c154d7221e970f65e30067574e.tar.gz
cpython-eb39294101ba45c154d7221e970f65e30067574e.tar.bz2
Silence 2to3 warnings in packaging tests
Diffstat (limited to 'Lib/packaging/tests/support.py')
-rw-r--r--Lib/packaging/tests/support.py12
1 files changed, 8 insertions, 4 deletions
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 @@ Each class or function has a docstring to explain its purpose and usage.
"""
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 @@ __all__ = ['LoggingCatcher', 'TempdirManager', 'EnvironRestorer',
'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 @@ class LoggingCatcher:
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 @@ class LoggingCatcher:
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):