2005-12-08 17:15:52 +00:00
|
|
|
|
# -*- coding: iso-8859-1 -*-
|
2006-02-03 18:34:12 +00:00
|
|
|
|
# Copyright (C) 2005 Joe Wreschnig
|
2010-03-05 11:49:54 +00:00
|
|
|
|
# Copyright (C) 2005-2010 Bastian Kleineidam
|
2005-12-08 17:15:52 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program 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 2 of the License, or
|
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program 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.
|
|
|
|
|
|
#
|
2009-07-24 21:58:20 +00:00
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-17 19:21:40 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test gettext .po files.
|
|
|
|
|
|
"""
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
2006-04-24 20:17:30 +00:00
|
|
|
|
import unittest
|
2005-12-08 17:15:52 +00:00
|
|
|
|
import os
|
|
|
|
|
|
import glob
|
2010-02-22 07:02:19 +00:00
|
|
|
|
from tests import need_msgfmt, need_posix
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pofiles = None
|
2010-03-13 07:47:12 +00:00
|
|
|
|
|
2005-12-18 08:13:55 +00:00
|
|
|
|
def get_pofiles ():
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""Find all .po files in this source."""
|
2005-12-08 17:15:52 +00:00
|
|
|
|
global pofiles
|
|
|
|
|
|
if pofiles is None:
|
|
|
|
|
|
pofiles = []
|
|
|
|
|
|
pofiles.extend(glob.glob("po/*.po"))
|
|
|
|
|
|
pofiles.extend(glob.glob("doc/*.po"))
|
2005-12-18 08:13:55 +00:00
|
|
|
|
return pofiles
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
2010-03-13 07:47:12 +00:00
|
|
|
|
|
2006-04-24 20:17:30 +00:00
|
|
|
|
class TestPo (unittest.TestCase):
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""Test .po file syntax."""
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
2010-02-22 07:02:19 +00:00
|
|
|
|
@need_posix
|
|
|
|
|
|
@need_msgfmt
|
2005-12-08 17:15:52 +00:00
|
|
|
|
def test_pos (self):
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""Test .po files syntax."""
|
2005-12-18 08:13:55 +00:00
|
|
|
|
for f in get_pofiles():
|
2005-12-08 17:15:52 +00:00
|
|
|
|
ret = os.system("msgfmt -c -o - %s > /dev/null" % f)
|
2010-03-05 09:00:34 +00:00
|
|
|
|
self.assertEqual(ret, 0, msg="PO-file syntax error in %r" % f)
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
2006-04-24 20:17:30 +00:00
|
|
|
|
class TestGTranslator (unittest.TestCase):
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""GTranslator displays a middot <20> for a space. Unfortunately, it
|
|
|
|
|
|
gets copied with copy-and-paste, what a shame."""
|
2005-12-08 17:15:52 +00:00
|
|
|
|
|
|
|
|
|
|
def test_gtranslator (self):
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""Test all pofiles for GTranslator brokenness."""
|
2005-12-18 08:13:55 +00:00
|
|
|
|
for f in get_pofiles():
|
2005-12-08 17:15:52 +00:00
|
|
|
|
fd = file(f)
|
|
|
|
|
|
try:
|
|
|
|
|
|
self.check_file(fd, f)
|
|
|
|
|
|
finally:
|
|
|
|
|
|
fd.close()
|
|
|
|
|
|
|
|
|
|
|
|
def check_file (self, fd, f):
|
2008-04-27 11:39:21 +00:00
|
|
|
|
"""Test for GTranslator broken syntax."""
|
2005-12-08 17:15:52 +00:00
|
|
|
|
for line in fd:
|
|
|
|
|
|
if line.strip().startswith("#"):
|
|
|
|
|
|
continue
|
2010-03-05 09:00:34 +00:00
|
|
|
|
self.assertFalse("\xc2\xb7" in line,
|
2005-12-08 17:15:52 +00:00
|
|
|
|
"Broken GTranslator copy/paste in %r:\n%r" % (f, line))
|