Suppress tests output

This commit is contained in:
Dmitry
2019-02-19 13:03:37 -08:00
parent c1cdf77414
commit fecaa5a0a2
5 changed files with 52 additions and 22 deletions
+20
View File
@@ -0,0 +1,20 @@
import logging
class MockLoggerHandlers(object):
def __init__(self, l, num=2):
self._logger = l
self._handlers = l.handlers
self._num = num
def __enter__(self):
self._logger.handlers = [
logging.FileHandler("tmp{}.log".format(i))
for i in range(self._num)
]
return self
def __exit__(self, exc_type=None, exc_val=None, exc_tb=None):
for h in self._logger.handlers:
h.close()
self._logger.handlers = self._handlers