mirror of https://github.com/python/cpython.git
Fixed test to work on Windows.
This commit is contained in:
parent
66b8b08752
commit
c2ad0aa9f1
|
@ -2342,28 +2342,28 @@ def remove_loop(fname, tries):
|
||||||
pass
|
pass
|
||||||
time.sleep(0.004 * random.randint(0, 4))
|
time.sleep(0.004 * random.randint(0, 4))
|
||||||
|
|
||||||
def cleanup(remover, fn, handler):
|
del_count = 500
|
||||||
handler.close()
|
log_count = 500
|
||||||
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()
|
|
||||||
for delay in (False, True):
|
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)
|
h = logging.handlers.WatchedFileHandler(fn, delay=delay)
|
||||||
self.addCleanup(cleanup, remover, fn, h)
|
|
||||||
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
|
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
|
||||||
h.setFormatter(f)
|
h.setFormatter(f)
|
||||||
for _ in range(log_count):
|
try:
|
||||||
time.sleep(0.005)
|
for _ in range(log_count):
|
||||||
r = logging.makeLogRecord({'msg': 'testing' })
|
time.sleep(0.005)
|
||||||
h.handle(r)
|
r = logging.makeLogRecord({'msg': 'testing' })
|
||||||
|
h.handle(r)
|
||||||
|
finally:
|
||||||
|
h.close()
|
||||||
|
remover.join()
|
||||||
|
if os.path.exists(fn):
|
||||||
|
os.unlink(fn)
|
||||||
|
|
||||||
|
|
||||||
# Set the locale to the platform-dependent default. I have no idea
|
# Set the locale to the platform-dependent default. I have no idea
|
||||||
|
|
Loading…
Reference in New Issue