summaryrefslogtreecommitdiff
path: root/tests/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/util.py')
-rwxr-xr-xtests/util.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/util.py b/tests/util.py
index 2ac6ff132..70f6b4351 100755
--- a/tests/util.py
+++ b/tests/util.py
@@ -46,6 +46,21 @@ class ClosingFileHandler(logging.StreamHandler):
super(ClosingFileHandler, self).emit(record)
self.setStream(None)
+ def setStream(self, stream):
+ setStream = getattr(super(ClosingFileHandler, self), 'setStream', None)
+ if callable(setStream):
+ return setStream(stream)
+ if stream is self.stream:
+ result = None
+ else:
+ result = self.stream
+ self.acquire()
+ try:
+ self.flush()
+ self.stream = stream
+ finally:
+ self.release()
+ return result
class TestData(object):
def __init__(self, data_folder):