[diffoscope] 01/04: progress: Reset prorgress bar internal statee after every test run.

Chris Lamb chris at chris-lamb.co.uk
Sun Feb 5 03:44:57 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 920d5fba4a9c2d885f7ff62a4dfab8005fb03232
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Feb 5 10:18:10 2017 +1300

    progress: Reset prorgress bar internal statee after every test run.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/progress.py | 9 ++++++---
 tests/conftest.py      | 5 +++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/diffoscope/progress.py b/diffoscope/progress.py
index 60bb912..1b2751f 100644
--- a/diffoscope/progress.py
+++ b/diffoscope/progress.py
@@ -32,9 +32,12 @@ class ProgressManager(object):
         self.__dict__ = self._singleton
 
         if not self._singleton:
-            self.total = 0
-            self.current = 0
-            self.observers = []
+            self.reset()
+
+    def reset(self):
+        self.total = 0
+        self.current = 0
+        self.observers = []
 
     def setup(self, parsed_args):
         # Show progress bar if user explicitly asked for it, otherwise show if
diff --git a/tests/conftest.py b/tests/conftest.py
index f50ee5b..55fdb0e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -20,6 +20,7 @@
 import pytest
 
 from diffoscope.locale import set_locale
+from diffoscope.progress import ProgressManager
 from diffoscope.comparators import ComparatorManager
 
 
@@ -31,3 +32,7 @@ def reload_comparators():
     # Reload Comparators after every test so we are always in a consistent
     # state
     ComparatorManager().reload()
+
+ at pytest.fixture(autouse=True)
+def reset_progress():
+    ProgressManager().reset()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list