]> granicus.if.org Git - python/commitdiff
Issue #11852: Add missing imports and update tests.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 15 Apr 2011 21:27:17 +0000 (22:27 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 15 Apr 2011 21:27:17 +0000 (22:27 +0100)
Lib/logging/handlers.py
Lib/test/test_logging.py
Misc/NEWS

index 96384bd7f7ec67156fbbd3dadaae305b9dcf54ca..3a48628d55f8dfc7c2d530707f2858dfbd3ae969 100644 (file)
@@ -26,6 +26,8 @@ To use, simply 'import logging.handlers' and log away!
 
 import logging, socket, os, pickle, struct, time, re
 from stat import ST_DEV, ST_INO, ST_MTIME
+import queue
+import threading
 
 try:
     import codecs
index b62545c815da1c82e2f23d23c8f4c7e25456d9a3..6623a0f532257626f91c538a2280689e6e5f99cf 100644 (file)
@@ -41,6 +41,7 @@ import struct
 import sys
 import tempfile
 from test.support import captured_stdout, run_with_locale, run_unittest
+from test.support import TestHandler, Matcher
 import textwrap
 import unittest
 import warnings
@@ -2092,6 +2093,21 @@ class QueueHandlerTest(BaseTest):
         self.assertEqual(data.name, self.que_logger.name)
         self.assertEqual((data.msg, data.args), (msg, None))
 
+    def test_queue_listener(self):
+        handler = TestHandler(Matcher())
+        listener = logging.handlers.QueueListener(self.queue, handler)
+        listener.start()
+        try:
+            self.que_logger.warning(self.next_message())
+            self.que_logger.error(self.next_message())
+            self.que_logger.critical(self.next_message())
+        finally:
+            listener.stop()
+        self.assertTrue(handler.matches(levelno=logging.WARNING, message='1'))
+        self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
+        self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))
+
+
 class FormatterTest(unittest.TestCase):
     def setUp(self):
         self.common = {
index fbb7411bdd2d39fcc88d0447df03c17ed3d065e9..01b5119b0ddaf115395be7481bb017a0eb73be89 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #11852: Add missing imports and update tests.
+
 - Issue #11467: Fix urlparse behavior when handling urls which contains scheme
   specific part only digits. Patch by Santoso Wijaya.