[Reproducible-commits] [debbindiff] 01/07: Add tests for bzip2 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 3ba38cf8e8bd4eefbd1d12545b9234da3debe9bf
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 09:57:41 2015 +0000

    Add tests for bzip2 comparator
---
 tests/comparators/test_bzip2.py |  52 ++++++++++++++++++++++++++++++++++++++++
 tests/data/test1.bz2            | Bin 0 -> 305 bytes
 tests/data/test2.bz2            | Bin 0 -> 466 bytes
 3 files changed, 52 insertions(+)

diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
new file mode 100644
index 0000000..7a04bc6
--- /dev/null
+++ b/tests/comparators/test_bzip2.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.bzip2 import compare_bzip2_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.bz2') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.bz2') 
+
+def test_no_differences():
+    differences = compare_bzip2_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_bzip2_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_bzip2_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.bz2 b/tests/data/test1.bz2
new file mode 100644
index 0000000..2d9e672
Binary files /dev/null and b/tests/data/test1.bz2 differ
diff --git a/tests/data/test2.bz2 b/tests/data/test2.bz2
new file mode 100644
index 0000000..15d1791
Binary files /dev/null and b/tests/data/test2.bz2 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