[Reproducible-commits] [diffoscope] 18/21: Add more tests for main() behavior
Jérémy Bobbio
lunar at moszumanska.debian.org
Mon Sep 21 17:39:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository diffoscope.
commit 9047d973184be3f0e357773fca31faf969555ff5
Author: Jérémy Bobbio <lunar at debian.org>
Date: Mon Sep 21 17:31:10 2015 +0200
Add more tests for main() behavior
---
tests/test_main.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/tests/test_main.py b/tests/test_main.py
index b1c4759..a79e9bb 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -91,3 +91,63 @@ def test_ctrl_c_handling(tmpdir, monkeypatch, capsys):
assert '' in err
assert excinfo.value.code == 2
assert os.listdir(str(tmpdir)) == []
+
+def test_text_option_with_file(tmpdir, capsys):
+ report_path = str(tmpdir.join('report.txt'))
+ args = ['--text', report_path, TEST_TAR1_PATH, TEST_TAR2_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 1
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert out == ''
+ with open(report_path, 'r') as f:
+ assert f.read().startswith('--- ')
+
+def test_text_option_with_stdiout(capsys):
+ args = ['--text', '-', TEST_TAR1_PATH, TEST_TAR2_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 1
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert out.startswith('--- ')
+
+def test_no_report_option(capsys):
+ args = [TEST_TAR1_PATH, TEST_TAR2_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 1
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert out.startswith('--- ')
+
+def test_html_option_with_file(tmpdir, capsys):
+ report_path = str(tmpdir.join('report.html'))
+ args = ['--html', report_path, TEST_TAR1_PATH, TEST_TAR2_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 1
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert out == ''
+ with open(report_path, 'r') as f:
+ assert 'meta name="generator" content="diffoscope"' in f.read()
+
+def test_html_option_with_stdout(capsys):
+ args = ['--html', '-', TEST_TAR1_PATH, TEST_TAR2_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 1
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert 'meta name="generator" content="diffoscope"' in out
+
+def test_no_differences(capsys):
+ args = [TEST_TAR1_PATH, TEST_TAR1_PATH]
+ with pytest.raises(SystemExit) as excinfo:
+ main(args)
+ assert excinfo.value.code == 0
+ out, err = capsys.readouterr()
+ assert err == ''
+ assert out == ''
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the Reproducible-commits
mailing list