[Reproducible-commits] [debbindiff] 02/06: Add tests for PNG comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 12:45:53 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 5d8453e379be614eb222b3ceeca8dc9c8565ed0b
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 12:10:00 2015 +0000

    Add tests for PNG comparator
---
 tests/comparators/test_png.py |  39 +++++++++++++++++++++++++++++++++++++++
 tests/data/png_expected_diff  |  10 ++++++++++
 tests/data/test1.png          | Bin 0 -> 69 bytes
 tests/data/test2.png          | Bin 0 -> 69 bytes
 4 files changed, 49 insertions(+)

diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
new file mode 100644
index 0000000..28dc2ec
--- /dev/null
+++ b/tests/comparators/test_png.py
@@ -0,0 +1,39 @@
+#!/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.png import compare_png_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.png') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.png') 
+
+def test_no_differences():
+    differences = compare_png_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_png_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_diff(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/png_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/png_expected_diff b/tests/data/png_expected_diff
new file mode 100644
index 0000000..b36e814
--- /dev/null
+++ b/tests/data/png_expected_diff
@@ -0,0 +1,10 @@
+@@ -1,8 +1,8 @@
+ #SNG: from stdin
+ IHDR {
+     width: 1; height: 1; bitdepth: 8;
+     using color;
+ }
+ IMAGE {
+-    pixels hex ffffff ;
++    pixels base64 777;
+ }
diff --git a/tests/data/test1.png b/tests/data/test1.png
new file mode 100644
index 0000000..5514ad4
Binary files /dev/null and b/tests/data/test1.png differ
diff --git a/tests/data/test2.png b/tests/data/test2.png
new file mode 100644
index 0000000..c5d9f31
Binary files /dev/null and b/tests/data/test2.png 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