# HG changeset patch # User Sylvain Thénault # Date 1375171558 -7200 # Node ID 1ba5961b19ddf5e1499abbdae015655a039470fc # Parent f66e2d331f4bde43fab20d5705fa25cbbe98d400 [i18n test] load_po: fix bug in case of multi-lines msgid and ensure there are no duplicated messages diff -r f66e2d331f4b -r 1ba5961b19dd devtools/test/unittest_i18n.py --- a/devtools/test/unittest_i18n.py Tue Jul 30 08:23:17 2013 +0200 +++ b/devtools/test/unittest_i18n.py Tue Jul 30 10:05:58 2013 +0200 @@ -28,30 +28,30 @@ DATADIR = osp.join(osp.abspath(osp.dirname(__file__)), 'data') def load_po(fname): - msgs = [] - msgid = None - msgctxt = None + """load a po file and return a set of encountered (msgid, msgctx)""" + msgs = set() + msgid = msgctxt = None for line in open(fname): if line.strip() in ('', '#'): continue if line.startswith('msgstr'): - msgs.append((msgid, msgctxt)) - msgid = None - msgctxt = None + assert not (msgid, msgctxt) in msgs + msgs.add( (msgid, msgctxt) ) + msgid = msgctxt = None elif line.startswith('msgid'): msgid = line.split(' ', 1)[1][1:-1] elif line.startswith('msgctx'): msgctxt = line.split(' ', 1)[1][1: -1] + elif msgid is not None: + msgid += line[1:-1] + elif msgctxt is not None: + msgctxt += line[1:-1] + return msgs - else: - if msgctxt is not None: - msgctxt += line[1:-1] - elif msgid is not None: - msgid += line[1:-1] - return set(msgs) class cubePotGeneratorTC(TestCase): """test case for i18n pot file generator""" + def setUp(self): self._CUBES_PATH = CubicWebNoAppConfiguration.CUBES_PATH[:] CubicWebNoAppConfiguration.CUBES_PATH.append(osp.join(DATADIR, 'cubes'))