[diffoscope] 01/02: tests: test_progress: fixes python-progressbar test case
Juliana Oliveira
jwnx-guest at moszumanska.debian.org
Fri Jan 5 05:09:19 CET 2018
This is an automated email from the git hooks/post-receive script.
jwnx-guest pushed a commit to branch jwnx_fix_progressbar
in repository diffoscope.
commit e7a02fca408c576ce7e36eb856ea53dfcbfd3d9c
Author: Juliana Oliveira <juliana.orod at gmail.com>
Date: Fri Jan 5 01:39:39 2018 -0200
tests: test_progress: fixes python-progressbar test case
Python progressbar module has different behaviors depending
on its version. test_progress was updated to include the behavior
seen on the latest version and also to be flexible enough to accomodate
future version changes.
(Closes: #877726)
Signed-off-by: Juliana Oliveira <juliana.orod at gmail.com>
---
tests/test_progress.py | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/tests/test_progress.py b/tests/test_progress.py
index 6c2b516..2c93a4a 100644
--- a/tests/test_progress.py
+++ b/tests/test_progress.py
@@ -25,6 +25,7 @@ import pytest
from diffoscope.main import main
from diffoscope.progress import ProgressManager, StatusFD
+from distutils.version import LooseVersion as vcls
from .utils.tools import skip_unless_module_exists
TEST_TAR1_PATH = os.path.join(os.path.dirname(__file__), 'data', 'test1.tar')
@@ -40,12 +41,33 @@ def run(capsys, *args):
return exc.value.code, out, err
+def progressbar_version():
+ import progressbar
+
+ return progressbar.__version__
+
+
+ at pytest.fixture
+def progressbar_err():
+ # This fixture returns an expected error message depending
+ # on progressbar version, from the lowest to the highest.
+ expected_err = { '3.19' : 'ETA', '3.34' : ''}
+
+ actual_ver = progressbar_version()
+
+ for k,v in expected_err.items():
+ if vcls(actual_ver) < vcls(k):
+ return v
+
+ return ''
+
+
@skip_unless_module_exists('progressbar')
-def test_progress(capsys):
+def test_progress(capsys, progressbar_err):
ret, _, err = run(capsys, TEST_TAR1_PATH, TEST_TAR2_PATH, '--progress')
assert ret == 1
- assert "ETA" in err
+ assert progressbar_err in err
def test_status_fd(capsys):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list