[Reproducible-commits] [debbindiff] 02/03: Add tests for Gettext comparators
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Jun 24 13:29:50 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 0e221d1a7b49e91574f6eca012a1678f67f885ef
Author: Jérémy Bobbio <lunar at debian.org>
Date: Wed Jun 24 13:26:40 2015 +0000
Add tests for Gettext comparators
---
tests/comparators/test_gettext.py | 47 +++++++++++++++++++++++++++++++++++
tests/data/mo_charsets_expected_diff | 22 ++++++++++++++++
tests/data/mo_expected_diff | 19 ++++++++++++++
tests/data/test1.mo | Bin 0 -> 397 bytes
tests/data/test2.mo | Bin 0 -> 443 bytes
tests/data/test_iso8859-1.mo | Bin 0 -> 458 bytes
tests/data/test_no_charset.mo | Bin 0 -> 428 bytes
7 files changed, 88 insertions(+)
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
new file mode 100644
index 0000000..1b1b70d
--- /dev/null
+++ b/tests/comparators/test_gettext.py
@@ -0,0 +1,47 @@
+#!/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 codecs
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.gettext import compare_mo_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.mo')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.mo')
+
+def test_no_differences():
+ differences = compare_mo_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+ assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+ return compare_mo_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/mo_expected_diff')).read()
+ assert differences[0].unified_diff == expected_diff
+
+def test_charsets():
+ differences = compare_mo_files(os.path.join(os.path.dirname(__file__), '../data/test_no_charset.mo'),
+ os.path.join(os.path.dirname(__file__), '../data/test_iso8859-1.mo'))
+ differences = differences[0].details # skip container with path
+ expected_diff = codecs.open(os.path.join(os.path.dirname(__file__), '../data/mo_charsets_expected_diff'), encoding='utf-8').read()
+ assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/mo_charsets_expected_diff b/tests/data/mo_charsets_expected_diff
new file mode 100644
index 0000000..789cb14
--- /dev/null
+++ b/tests/data/mo_charsets_expected_diff
@@ -0,0 +1,22 @@
+@@ -1,17 +1,17 @@
+ msgid ""
+ msgstr ""
+ "Project-Id-Version: debbindiff\n"
+ "POT-Creation-Date: 2015-06-24 12:42+0200\n"
+ "PO-Revision-Date: 2015-06-24 14:57+0200\n"
+ "Last-Translator: Someone <user at example.org>\n"
+-"Language-Team: English <user at example.org>\n"
++"Language-Team: Français <user at example.org>\n"
+ "Language: en\n"
+ "MIME-Version: 1.0\n"
+-"Content-Type: text/plain\n"
++"Content-Type: text/plain; charset=iso8859-1\n"
+ "Content-Transfer-Encoding: 8bit\n"
+
+ msgid "Another string"
+-msgstr "Another string"
++msgstr "Une chaine, là aussi"
+
+ msgid "String"
+-msgstr "String"
++msgstr "Chaine, là"
diff --git a/tests/data/mo_expected_diff b/tests/data/mo_expected_diff
new file mode 100644
index 0000000..bac053b
--- /dev/null
+++ b/tests/data/mo_expected_diff
@@ -0,0 +1,19 @@
+@@ -1,14 +1,17 @@
+ msgid ""
+ msgstr ""
+ "Project-Id-Version: debbindiff\n"
+ "POT-Creation-Date: 2015-06-24 12:42+0200\n"
+-"PO-Revision-Date: 2015-06-24 12:42+0200\n"
++"PO-Revision-Date: 2015-06-24 14:57+0200\n"
+ "Last-Translator: Someone <user at example.org>\n"
+ "Language-Team: English <user at example.org>\n"
+ "Language: en\n"
+ "MIME-Version: 1.0\n"
+ "Content-Type: text/plain; charset=UTF-8\n"
+ "Content-Transfer-Encoding: 8bit\n"
+
++msgid "Another string"
++msgstr "Another string"
++
+ msgid "String"
+ msgstr "String"
diff --git a/tests/data/test1.mo b/tests/data/test1.mo
new file mode 100644
index 0000000..55dfdf9
Binary files /dev/null and b/tests/data/test1.mo differ
diff --git a/tests/data/test2.mo b/tests/data/test2.mo
new file mode 100644
index 0000000..afdda04
Binary files /dev/null and b/tests/data/test2.mo differ
diff --git a/tests/data/test_iso8859-1.mo b/tests/data/test_iso8859-1.mo
new file mode 100644
index 0000000..9ee255a
Binary files /dev/null and b/tests/data/test_iso8859-1.mo differ
diff --git a/tests/data/test_no_charset.mo b/tests/data/test_no_charset.mo
new file mode 100644
index 0000000..c790b8e
Binary files /dev/null and b/tests/data/test_no_charset.mo 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