diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-04-25 09:51:35 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-04-25 09:51:35 (GMT) |
commit | c94871a5c076e7fd82ccc5f055065d3911f46d40 (patch) | |
tree | d37a9f7332ae3acb89d5b5a0b968f3a7ac5fbb32 /Lib/test/test_logging.py | |
parent | 7541c8ea37e56e5b5ee9b6276b100052ee500ae6 (diff) | |
parent | c2ad0aa9f1bc89e6da38f81af9ca05e921fa725c (diff) | |
download | cpython-c94871a5c076e7fd82ccc5f055065d3911f46d40.zip cpython-c94871a5c076e7fd82ccc5f055065d3911f46d40.tar.gz cpython-c94871a5c076e7fd82ccc5f055065d3911f46d40.tar.bz2 |
Merged fixed test from 3.2.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index ee1c211..2279952 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -593,28 +593,28 @@ class HandlerTest(BaseTest): 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) + del_count = 500 + log_count = 500 - 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() 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): |