[Python-checkins] cpython (merge 3.2 -> default): Merged fixed test from 3.2.

vinay.sajip python-checkins at python.org
Wed Apr 25 11:51:48 CEST 2012


http://hg.python.org/cpython/rev/8965693ecb14
changeset:   76552:8965693ecb14
parent:      76549:acfdf46b8de1
parent:      76551:59bc2d9497b0
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Wed Apr 25 10:51:35 2012 +0100
summary:
  Merged fixed test from 3.2.

files:
  Lib/test/test_logging.py |  36 ++++++++++++++--------------
  1 files changed, 18 insertions(+), 18 deletions(-)


diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -593,28 +593,28 @@
                     pass
                 time.sleep(0.004 * random.randint(0, 4))
 
-        def cleanup(remover, fn, handler):
-            handler.close()
-            remover.join()
-            if os.path.exists(fn):
-                os.unlink(fn)
-
-        fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
-        os.close(fd)
-        del_count = 1000
-        log_count = 1000
-        remover = threading.Thread(target=remove_loop, args=(fn, del_count))
-        remover.daemon = True
-        remover.start()
+        del_count = 500
+        log_count = 500
+
         for delay in (False, True):
+            fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
+            os.close(fd)
+            remover = threading.Thread(target=remove_loop, args=(fn, del_count))
+            remover.daemon = True
+            remover.start()
             h = logging.handlers.WatchedFileHandler(fn, delay=delay)
-            self.addCleanup(cleanup, remover, fn, h)
             f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
             h.setFormatter(f)
-            for _ in range(log_count):
-                time.sleep(0.005)
-                r = logging.makeLogRecord({'msg': 'testing' })
-                h.handle(r)
+            try:
+                for _ in range(log_count):
+                    time.sleep(0.005)
+                    r = logging.makeLogRecord({'msg': 'testing' })
+                    h.handle(r)
+            finally:
+                h.close()
+                remover.join()
+                if os.path.exists(fn):
+                    os.unlink(fn)
 
 
 class BadStream(object):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list