[Reproducible-commits] [diffoscope] 03/03: Add a test on how Ctrl+C is handled

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Sep 3 15:58:27 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 cfc27d3d8c9d34fa46ea6b97f1b3e542f8ff2a9a
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Sep 3 15:57:14 2015 +0000

    Add a test on how Ctrl+C is handled
---
 tests/test_main.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/test_main.py b/tests/test_main.py
index 87c306b..125162b 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -79,3 +79,16 @@ def test_remove_temp_files_on_sigterm(tmpdir, monkeypatch):
         _, ret = os.waitpid(pid, 0)
         assert (ret >> 8) == 2 # having received SIGTERM is trouble
         assert os.listdir(str(tmpdir)) == []
+
+def test_ctrl_c_handling(tmpdir, monkeypatch, capsys):
+    args = [TEST_TAR1_PATH, TEST_TAR2_PATH]
+    monkeypatch.setattr('tempfile.tempdir', str(tmpdir))
+    def interrupt(*args):
+        raise KeyboardInterrupt
+    monkeypatch.setattr('diffoscope.comparators.text.TextFile.compare', interrupt)
+    with pytest.raises(SystemExit) as excinfo:
+        main(args)
+    out, err = capsys.readouterr()
+    assert '' in err
+    assert excinfo.value.code == 2
+    assert os.listdir(str(tmpdir)) == []

-- 
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