[diffoscope] 04/04: tests: Test the --status-fd output.

Chris Lamb chris at chris-lamb.co.uk
Sun Feb 5 03:44:58 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 c9696b6e425c913315ac6418c883d72bd7b18c17
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Feb 5 15:41:13 2017 +1300

    tests: Test the --status-fd output.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/test_progress.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/test_progress.py b/tests/test_progress.py
index 08cc9c6..74fad00 100644
--- a/tests/test_progress.py
+++ b/tests/test_progress.py
@@ -18,9 +18,12 @@
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
 import os
+import sys
+import json
 import pytest
 
 from diffoscope.main import main
+from diffoscope.progress import ProgressManager, StatusFD
 
 TEST_TAR1_PATH = os.path.join(os.path.dirname(__file__), 'data', 'test1.tar')
 TEST_TAR2_PATH = os.path.join(os.path.dirname(__file__), 'data', 'test2.tar')
@@ -39,3 +42,22 @@ def test_progress(capsys):
 
     assert ret == 1
     assert "ETA" in err
+
+def test_status_fd(capsys):
+    ProgressManager().register(StatusFD(sys.stderr))
+
+    ret, _, err = run(capsys, TEST_TAR1_PATH, TEST_TAR2_PATH)
+
+    assert ret == 1
+
+    # Parse lines and ensure we emitted at least one line
+    output = [json.loads(x) for x in err.splitlines()]
+    assert output
+
+    # Ensure each line is valid
+    for x in output:
+        assert 'msg' in x
+        assert x['current'] <= x['total']
+
+    # Last line should mark us as "complete"
+    assert output[-1]['current'] == output[-1]['total']

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


More information about the diffoscope mailing list