summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-11-07 18:43:05 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-11-07 18:43:05 (GMT)
commit5252f9faee97573f5b8ff37d7c22225e5df6cc0b (patch)
tree780ab582475f423f45005bb673623e3e007e7716 /Lib/test/test_logging.py
parent1cdbf57c7cabaa0451cfcf04583f31c9a7eab38d (diff)
downloadcpython-5252f9faee97573f5b8ff37d7c22225e5df6cc0b.zip
cpython-5252f9faee97573f5b8ff37d7c22225e5df6cc0b.tar.gz
cpython-5252f9faee97573f5b8ff37d7c22225e5df6cc0b.tar.bz2
logging: replace codecs.open with builtins.open, remove '_encoded' sort, add some tests.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index ed22d91..25ca0b8 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -49,6 +49,7 @@ import weakref
try:
import threading
# The following imports are needed only for tests which
+ # require threading
import asynchat
import asyncore
import errno
@@ -95,9 +96,7 @@ class BaseTest(unittest.TestCase):
finally:
logging._releaseLock()
- # Set two unused loggers: one non-ASCII and one Unicode.
- # This is to test correct operation when sorting existing
- # loggers in the configuration code. See issue 8201.
+ # Set two unused loggers
self.logger1 = logging.getLogger("\xab\xd7\xbb")
self.logger2 = logging.getLogger("\u013f\u00d6\u0047")
@@ -310,8 +309,6 @@ class BuiltinLevelsTest(BaseTest):
('INF.BADPARENT', 'INFO', '4'),
])
- def test_invalid_name(self):
- self.assertRaises(TypeError, logging.getLogger, any)
class BasicFilterTest(BaseTest):
@@ -3514,6 +3511,22 @@ class LoggerTest(BaseTest):
self.addCleanup(setattr, self.logger.manager, 'disable', old_disable)
self.assertFalse(self.logger.isEnabledFor(22))
+ def test_root_logger_aliases(self):
+ root = logging.getLogger()
+ self.assertIs(root, logging.root)
+ self.assertIs(root, logging.getLogger(None))
+ self.assertIs(root, logging.getLogger(''))
+ self.assertIs(root, logging.getLogger('foo').root)
+ self.assertIs(root, logging.getLogger('foo.bar').root)
+ self.assertIs(root, logging.getLogger('foo').parent)
+
+ self.assertIsNot(root, logging.getLogger('\0'))
+ self.assertIsNot(root, logging.getLogger('foo.bar').parent)
+
+ def test_invalid_names(self):
+ self.assertRaises(TypeError, logging.getLogger, any)
+ self.assertRaises(TypeError, logging.getLogger, b'foo')
+
class BaseFileTest(BaseTest):
"Base class for handler tests that write log files"