[diffoscope] 03/03: Add tests for OutputParserError and ContainerExtractionError.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Sun May 7 16:14:36 CEST 2017


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

siamezzze-guest pushed a commit to branch experimental
in repository diffoscope.

commit bb3555b7518b47ec37363a67239e4a97da6857e4
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Sun May 7 16:58:09 2017 +0300

    Add tests for OutputParserError and ContainerExtractionError.
---
 tests/comparators/test_binary.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index 64602ef..bca69d4 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -135,6 +135,30 @@ def test_with_compare_details_and_failed_process():
     assert normalize_zeros(difference.unified_diff) == expected_diff
 
 @skip_unless_tools_exist('xxd')
+def test_with_compare_details_and_parsing_error():
+    from diffoscope.exc import OutputParsingError
+    class MockFile(FilesystemFile):
+        def compare_details(self, other, source=None):
+            subprocess.check_output(['sh', '-c', 'exit 0'], shell=False)
+            raise OutputParsingError('sh', self)
+    difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
+    expected_diff = get_data('../data/binary_expected_diff')
+    assert 'Error parsing output' in difference.comment
+    assert normalize_zeros(difference.unified_diff) == expected_diff
+
+ at skip_unless_tools_exist('xxd')
+def test_with_compare_details_and_extraction_error():
+    from diffoscope.exc import ContainerExtractionError
+    class MockFile(FilesystemFile):
+        def compare_details(self, other, source=None):
+            subprocess.check_output(['sh', '-c', 'exit 0'], shell=False)
+            raise ContainerExtractionError(self.path, Exception())
+    difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
+    expected_diff = get_data('../data/binary_expected_diff')
+    assert 'Error extracting' in difference.comment
+    assert normalize_zeros(difference.unified_diff) == expected_diff
+
+ at skip_unless_tools_exist('xxd')
 def test_with_compare_details_and_tool_not_found(monkeypatch):
     from diffoscope.external_tools import EXTERNAL_TOOLS
     monkeypatch.setitem(

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


More information about the diffoscope mailing list