def delete_logs():
if hasattr(atexit, "_clear"):
atexit._clear()
elif hasattr(atexit, "_exithandlers"):
atexit._exithandlers[:] = [] # stop the logging module's exit handler
for suffix in Logger.LEVELS:
filename = "unit_tests.{0}_log".format(suffix)
if os.path.exists(filename):
handlers = logging.getLogger("unit_tests." + suffix).handlers
if handlers and handlers[0].stream:
handlers[0].stream.close()
os.remove(filename)
评论列表
文章目录