Commit 0e221d1a authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add tests for Gettext comparators

parent abcbb5dd
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# debbindiff: highlight differences between two builds of Debian packages
# Copyright © 2015 Jérémy Bobbio <>
# 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
# 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 <>.
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/')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/')
def test_no_differences():
differences = compare_mo_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
assert len(differences) == 0
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/'),
os.path.join(os.path.dirname(__file__), '../data/'))
differences = differences[0].details # skip container with path
expected_diff =, '../data/mo_charsets_expected_diff'), encoding='utf-8').read()
assert differences[0].unified_diff == expected_diff
@@ -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 <>\n"
-"Language-Team: English <>\n"
+"Language-Team: Français <>\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à"
@@ -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 <>\n"
"Language-Team: English <>\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"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment