[Reproducible-commits] [debbindiff] 02/07: Add tests for xz comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 11:52:25 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit f1a19e310b03a9b01864bf460e08aa7c7e3fc8e9
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 10:19:29 2015 +0000

    Add tests for xz comparator
---
 tests/comparators/test_xz.py |  52 +++++++++++++++++++++++++++++++++++++++++++
 tests/data/test1.xz          | Bin 0 -> 388 bytes
 tests/data/test2.xz          | Bin 0 -> 532 bytes
 3 files changed, 52 insertions(+)

diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
new file mode 100644
index 0000000..cf51d61
--- /dev/null
+++ b/tests/comparators/test_xz.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# debbindiff is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.xz import compare_xz_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.xz') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.xz') 
+
+def test_no_differences():
+    differences = compare_xz_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_xz_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_content_source(differences):
+    assert differences[0].source1 == 'test1'
+    assert differences[0].source2 == 'test2'
+
+def test_content_source_without_extension(tmpdir):
+    path1 = str(tmpdir.join('test1'))
+    path2 = str(tmpdir.join('test2'))
+    shutil.copy(TEST_FILE1_PATH, path1)
+    shutil.copy(TEST_FILE2_PATH, path2)
+    differences = compare_xz_files(path1, path2)[0].details # skip container
+    assert differences[0].source1 == 'test1-content'
+    assert differences[0].source2 == 'test2-content'
+
+def test_content_diff(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/test1.xz b/tests/data/test1.xz
new file mode 100644
index 0000000..a017461
Binary files /dev/null and b/tests/data/test1.xz differ
diff --git a/tests/data/test2.xz b/tests/data/test2.xz
new file mode 100644
index 0000000..f95240b
Binary files /dev/null and b/tests/data/test2.xz differ

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



More information about the Reproducible-commits mailing list