[diffoscope] 01/01: Fix failing tests due to stupid logging global state
Ximin Luo
infinity0 at debian.org
Wed May 24 22:06:45 CEST 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch experimental
in repository diffoscope.
commit 84f80f53f33951d8356e7569d60876dda7319255
Author: Ximin Luo <infinity0 at debian.org>
Date: Wed May 24 22:06:15 2017 +0200
Fix failing tests due to stupid logging global state
---
diffoscope/progress.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/diffoscope/progress.py b/diffoscope/progress.py
index 49a36f6..9d4dbdf 100644
--- a/diffoscope/progress.py
+++ b/diffoscope/progress.py
@@ -29,15 +29,21 @@ class ProgressLoggingHandler(logging.StreamHandler):
def __init__(self, progressbar):
self.progressbar = progressbar
- logging.StreamHandler.__init__(self)
+ super().__init__()
def emit(self, record):
- # delete the current line (i.e. the progress bar)
- self.stream.write("\r\033[K")
- self.flush()
- logging.StreamHandler.emit(self, record)
- if not self.progressbar.bar.finished:
- self.progressbar.bar.update()
+ try:
+ # delete the current line (i.e. the progress bar)
+ self.stream.write("\r\033[K")
+ self.flush()
+ super().emit(record)
+ if not self.progressbar.bar.finished:
+ self.progressbar.bar.update()
+ except Exception:
+ # have to do this try-except wrapping otherwise tests fail
+ # due to test_progress.py running main() several times.
+ # this mirrors the super() implementation.
+ self.handleError(record)
class ProgressManager(object):
_singleton = {}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list