diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-04-27 11:31:14 +0100 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-04-27 11:31:14 +0100 |
commit | 4d0edf5e7e4cf78f802e45885d970d8088f61c07 (patch) | |
tree | b8ed2a5656dbe426c97bff5221d72d00e53afff1 /Lib/test/test_logging.py | |
parent | ff53f493ba74724bcb8b18b4899b3a3a8ba32169 (diff) | |
download | cpython-4d0edf5e7e4cf78f802e45885d970d8088f61c07.tar.gz |
test_logging coverage improvements.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index e35a614ab4..567d084f0b 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -508,8 +508,50 @@ class HandlerTest(BaseTest): self.assertEqual(h.name, 'anothergeneric') self.assertRaises(NotImplementedError, h.emit, None) - def test_abc(self): - pass + def test_builtin_handlers(self): + # We can't actually *use* too many handlers in the tests, + # but we can try instantiating them with various options + if sys.platform in ('linux2', 'darwin'): + for existing in (True, False): + fd, fn = tempfile.mkstemp() + os.close(fd) + if not existing: + os.unlink(fn) + h = logging.handlers.WatchedFileHandler(fn, delay=True) + if existing: + self.assertNotEqual(h.dev, -1) + self.assertNotEqual(h.ino, -1) + else: + self.assertEqual(h.dev, -1) + self.assertEqual(h.ino, -1) + h.close() + if existing: + os.unlink(fn) + if sys.platform == 'darwin': + sockname = '/var/run/log' + else: + sockname = '/dev/log' + h = logging.handlers.SysLogHandler(sockname) + self.assertEqual(h.facility, h.LOG_USER) + self.assertTrue(h.unixsocket) + h.close() + h = logging.handlers.SMTPHandler('localhost', 'me', 'you', 'Log') + self.assertEqual(h.toaddrs, ['you']) + h.close() + for method in ('GET', 'POST', 'PUT'): + if method == 'PUT': + self.assertRaises(ValueError, logging.handlers.HTTPHandler, + 'localhost', '/log', method) + else: + h = logging.handlers.HTTPHandler('localhost', '/log', method) + h.close() + h = logging.handlers.BufferingHandler(0) + r = logging.makeLogRecord({}) + self.assertTrue(h.shouldFlush(r)) + h.close() + h = logging.handlers.BufferingHandler(1) + self.assertFalse(h.shouldFlush(r)) + h.close() class BadStream(object): def write(self, data): |