[diffoscope] 04/05: tests: Add utilities for actually testing output formats.

Chris Lamb chris at chris-lamb.co.uk
Sat Jan 21 06:11:15 CET 2017


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

lamby pushed a commit to branch lamby/output-formats
in repository diffoscope.

commit d589e08837387c6597e18b3326ce7e7d08251ee0
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Jan 21 15:59:15 2017 +1100

    tests: Add utilities for actually testing output formats.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/test_presenters.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index a601ed8..8dd537f 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -22,14 +22,18 @@ import pytest
 
 from diffoscope.main import main
 
-def run(capsys, *args):
-    args = list(args) + [
-        os.path.join(os.path.dirname(__file__), 'data', x)
-        for x in ('test1.tar', 'test2.tar')
-    ]
+DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
+
 
+def run(capsys, *args):
     with pytest.raises(SystemExit) as exc:
-        main(args)
+        prev = os.getcwd()
+        os.chdir(DATA_DIR)
+
+        try:
+            main(args + ('test1.tar', 'test2.tar'))
+        finally:
+            os.chdir(prev)
 
     out, err = capsys.readouterr()
 
@@ -38,6 +42,10 @@ def run(capsys, *args):
 
     return out
 
+def data(filename):
+    with open(os.path.join(DATA_DIR, filename)) as f:
+        return f.read()
+
 def test_text_option_with_file(tmpdir, capsys):
     report_path = str(tmpdir.join('report.txt'))
 

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


More information about the diffoscope mailing list