annotate Lib/test/test_gettext.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 06145fbc7ab9
children beacf40b5960 85542715a249
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14188
6223397bd6a2 Test suite for new gettext.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
1 import os
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
2 import base64
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
3 import shutil
14188
6223397bd6a2 Test suite for new gettext.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
4 import gettext
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
5 import unittest
14188
6223397bd6a2 Test suite for new gettext.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
6
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 36593
diff changeset
7 from test import test_support
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
8
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
9
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
10 # TODO:
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
11 # - Add new tests, for example for "dgettext"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
12 # - Remove dummy tests, for example testing for single and double quotes
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
13 # has no sense, it would have if we were testing a parser (i.e. pygettext)
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
14 # - Tests should have only one assert.
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
15
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
16 GNU_MO_DATA = '''\
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
17 3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
18 AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
19 AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
20 eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
21 aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
22 CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
23 Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
24 ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
25 MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
26 YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
27 SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
28 NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
29 ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
30 d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
31 eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
32 IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
33 ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA==
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
34 '''
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
35
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
36 UMO_DATA = '''\
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
37 3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABAAAAFEAAAAPAQAAVgAAAAQAAABm
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
38 AQAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAYWLDngBQcm9qZWN0LUlkLVZlcnNpb246IDIuMApQTy1S
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
39 ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
40 eSBBLiBXQXJzYXcgPGJhcnJ5QHB5dGhvbi5vcmc+Ckxhbmd1YWdlLVRlYW06IFhYIDxweXRob24t
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
41 ZGV2QHB5dGhvbi5vcmc+Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFp
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
42 bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
43 ZC1CeTogbWFudWFsbHkKAMKkeXoA
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
44 '''
15305
07f24261c6e6 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 14591
diff changeset
45
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
46 MMO_DATA = '''\
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
47 3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
48 UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
49 IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
50 NTgrMDA6MDAKTGFzdC1UcmFuc2xhdG9yOiBKb2huIERvZSA8amRvZUBleGFtcGxlLmNvbT4KSmFu
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
51 ZSBGb29iYXIgPGpmb29iYXJAZXhhbXBsZS5jb20+Ckxhbmd1YWdlLVRlYW06IHh4IDx4eEBleGFt
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
52 cGxlLmNvbT4KTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFy
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
53 c2V0PWlzby04ODU5LTE1CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFi
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
54 bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA=
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
55 '''
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
56
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
57 LOCALEDIR = os.path.join('xx', 'LC_MESSAGES')
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
58 MOFILE = os.path.join(LOCALEDIR, 'gettext.mo')
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
59 UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo')
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
60 MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo')
28867
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
61 try:
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
62 LANG = os.environ['LANGUAGE']
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
63 except:
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
64 LANG = 'en'
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
65
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
66
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
67 class GettextBaseTest(unittest.TestCase):
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
68 def setUp(self):
32751
95eb6e18a542 Don't try to create the directory if it already exists, otherwise the test fails
Neal Norwitz <nnorwitz@gmail.com>
parents: 29191
diff changeset
69 if not os.path.isdir(LOCALEDIR):
95eb6e18a542 Don't try to create the directory if it already exists, otherwise the test fails
Neal Norwitz <nnorwitz@gmail.com>
parents: 29191
diff changeset
70 os.makedirs(LOCALEDIR)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
71 fp = open(MOFILE, 'wb')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
72 fp.write(base64.decodestring(GNU_MO_DATA))
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
73 fp.close()
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
74 fp = open(UMOFILE, 'wb')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
75 fp.write(base64.decodestring(UMO_DATA))
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
76 fp.close()
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
77 fp = open(MMOFILE, 'wb')
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
78 fp.write(base64.decodestring(MMO_DATA))
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
79 fp.close()
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
80 os.environ['LANGUAGE'] = 'xx'
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
81
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
82 def tearDown(self):
28867
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
83 os.environ['LANGUAGE'] = LANG
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
84 shutil.rmtree(os.path.split(LOCALEDIR)[0])
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
85
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
86
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
87 class GettextTestCase1(GettextBaseTest):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
88 def setUp(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
89 GettextBaseTest.setUp(self)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
90 self.localedir = os.curdir
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
91 self.mofile = MOFILE
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
92 gettext.install('gettext', self.localedir)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
93
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
94 def test_some_translations(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
95 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
96 # test some translations
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
97 eq(_('albatross'), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
98 eq(_(u'mullusk'), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
99 eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
100 eq(_(ur'nudge nudge'), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
101
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
102 def test_double_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
103 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
104 # double quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
105 eq(_("albatross"), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
106 eq(_(u"mullusk"), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
107 eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
108 eq(_(ur"nudge nudge"), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
109
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
110 def test_triple_single_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
111 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
112 # triple single quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
113 eq(_('''albatross'''), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
114 eq(_(u'''mullusk'''), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
115 eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
116 eq(_(ur'''nudge nudge'''), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
117
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
118 def test_triple_double_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
119 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
120 # triple double quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
121 eq(_("""albatross"""), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
122 eq(_(u"""mullusk"""), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
123 eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
124 eq(_(ur"""nudge nudge"""), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
125
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
126 def test_multiline_strings(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
127 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
128 # multiline strings
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
129 eq(_('''This module provides internationalization and localization
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
130 support for your Python programs by providing an interface to the GNU
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
131 gettext message catalog library.'''),
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
132 '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
133 fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
134 trggrkg zrffntr pngnybt yvoenel.''')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
135
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
136 def test_the_alternative_interface(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
137 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
138 # test the alternative interface
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
139 fp = open(self.mofile, 'rb')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
140 t = gettext.GNUTranslations(fp)
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
141 fp.close()
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
142 # Install the translation object
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
143 t.install()
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
144 eq(_('nudge nudge'), 'wink wink')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
145 # Try unicode return type
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
146 t.install(unicode=True)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
147 eq(_('mullusk'), 'bacon')
36593
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
148 # Test installation of other methods
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
149 import __builtin__
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
150 t.install(unicode=True, names=["gettext", "lgettext"])
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
151 eq(_, t.ugettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
152 eq(__builtin__.gettext, t.ugettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
153 eq(lgettext, t.lgettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
154 del __builtin__.gettext
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
155 del __builtin__.lgettext
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
156
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
157
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
158 class GettextTestCase2(GettextBaseTest):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
159 def setUp(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
160 GettextBaseTest.setUp(self)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
161 self.localedir = os.curdir
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
162 # Set up the bindings
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
163 gettext.bindtextdomain('gettext', self.localedir)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
164 gettext.textdomain('gettext')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
165 # For convenience
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
166 self._ = gettext.gettext
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
167
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
168 def test_bindtextdomain(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
169 self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
170
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
171 def test_textdomain(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
172 self.assertEqual(gettext.textdomain(), 'gettext')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
173
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
174 def test_some_translations(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
175 eq = self.assertEqual
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
176 # test some translations
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
177 eq(self._('albatross'), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
178 eq(self._(u'mullusk'), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
179 eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
180 eq(self._(ur'nudge nudge'), 'wink wink')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
181
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
182 def test_double_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
183 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
184 # double quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
185 eq(self._("albatross"), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
186 eq(self._(u"mullusk"), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
187 eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
188 eq(self._(ur"nudge nudge"), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
189
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
190 def test_triple_single_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
191 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
192 # triple single quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
193 eq(self._('''albatross'''), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
194 eq(self._(u'''mullusk'''), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
195 eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
196 eq(self._(ur'''nudge nudge'''), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
197
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
198 def test_triple_double_quotes(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
199 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
200 # triple double quotes
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
201 eq(self._("""albatross"""), 'albatross')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
202 eq(self._(u"""mullusk"""), 'bacon')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
203 eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
204 eq(self._(ur"""nudge nudge"""), 'wink wink')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
205
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
206 def test_multiline_strings(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
207 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
208 # multiline strings
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
209 eq(self._('''This module provides internationalization and localization
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
210 support for your Python programs by providing an interface to the GNU
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
211 gettext message catalog library.'''),
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
212 '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
213 fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
214 trggrkg zrffntr pngnybt yvoenel.''')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
215
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
216
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
217 class PluralFormsTestCase(GettextBaseTest):
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
218 def setUp(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
219 GettextBaseTest.setUp(self)
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
220 self.mofile = MOFILE
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
221
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
222 def test_plural_forms1(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
223 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
224 x = gettext.ngettext('There is %s file', 'There are %s files', 1)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
225 eq(x, 'Hay %s fichero')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
226 x = gettext.ngettext('There is %s file', 'There are %s files', 2)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
227 eq(x, 'Hay %s ficheros')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
228
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
229 def test_plural_forms2(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
230 eq = self.assertEqual
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
231 fp = open(self.mofile, 'rb')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
232 t = gettext.GNUTranslations(fp)
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
233 fp.close()
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
234 x = t.ngettext('There is %s file', 'There are %s files', 1)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
235 eq(x, 'Hay %s fichero')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
236 x = t.ngettext('There is %s file', 'There are %s files', 2)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
237 eq(x, 'Hay %s ficheros')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
238
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
239 def test_hu(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
240 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
241 f = gettext.c2py('0')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
242 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
243 eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
244
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
245 def test_de(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
246 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
247 f = gettext.c2py('n != 1')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
248 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
249 eq(s, "10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
250
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
251 def test_fr(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
252 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
253 f = gettext.c2py('n>1')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
254 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
255 eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
256
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
257 def test_gd(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
258 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
259 f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
260 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
261 eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
262
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
263 def test_gd2(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
264 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
265 # Tests the combination of parentheses and "?:"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
266 f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
267 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
268 eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
269
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
270 def test_lt(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
271 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
272 f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
273 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
274 eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
275
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
276 def test_ru(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
277 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
278 f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
279 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
280 eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
281
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
282 def test_pl(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
283 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
284 f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
285 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
286 eq(s, "20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
287
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
288 def test_sl(self):
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
289 eq = self.assertEqual
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
290 f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3')
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
291 s = ''.join([ str(f(x)) for x in range(200) ])
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
292 eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
293
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
294 def test_security(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
295 raises = self.assertRaises
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
296 # Test for a dangerous expression
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
297 raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
298
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
299
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
300 class UnicodeTranslationsTest(GettextBaseTest):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
301 def setUp(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
302 GettextBaseTest.setUp(self)
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
303 fp = open(UMOFILE, 'rb')
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
304 try:
28794
05e57388cb8f UnicodeTranslationsTest.setUp(): Removed the coerce flag to the
Barry Warsaw <barry@python.org>
parents: 28774
diff changeset
305 self.t = gettext.GNUTranslations(fp)
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
306 finally:
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
307 fp.close()
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
308 self._ = self.t.ugettext
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
309
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
310 def test_unicode_msgid(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
311 unless = self.failUnless
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
312 unless(isinstance(self._(''), unicode))
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
313 unless(isinstance(self._(u''), unicode))
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
314
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
315 def test_unicode_msgstr(self):
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
316 eq = self.assertEqual
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
317 eq(self._(u'ab\xde'), u'\xa4yz')
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
318
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
319
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
320 class WeirdMetadataTest(GettextBaseTest):
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
321 def setUp(self):
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
322 GettextBaseTest.setUp(self)
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
323 fp = open(MMOFILE, 'rb')
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
324 try:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
325 try:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
326 self.t = gettext.GNUTranslations(fp)
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
327 except:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
328 self.tearDown()
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
329 raise
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
330 finally:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
331 fp.close()
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
332
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
333 def test_weird_metadata(self):
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
334 info = self.t.info()
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
335 self.assertEqual(info['last-translator'],
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
336 'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>')
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
337
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
338
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
339 def test_main():
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 36593
diff changeset
340 test_support.run_unittest(__name__)
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
341
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
342 if __name__ == '__main__':
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
343 test_main()
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
344
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
345
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
346 # For reference, here's the .po file used to created the GNU_MO_DATA above.
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
347 #
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
348 # The original version was automatically generated from the sources with
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
349 # pygettext. Later it was manually modified to add plural forms support.
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
350
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
351 '''
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
352 # Dummy translation for the Python test_gettext.py module.
19483
c171b07bf6a9 Quick and dirty fix for test_extcall failures trigged by Guido's
Barry Warsaw <barry@python.org>
parents: 15305
diff changeset
353 # Copyright (C) 2001 Python Software Foundation
c171b07bf6a9 Quick and dirty fix for test_extcall failures trigged by Guido's
Barry Warsaw <barry@python.org>
parents: 15305
diff changeset
354 # Barry Warsaw <barry@python.org>, 2000.
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
355 #
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
356 msgid ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
357 msgstr ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
358 "Project-Id-Version: 2.0\n"
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
359 "PO-Revision-Date: 2003-04-11 14:32-0400\n"
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
360 "Last-Translator: J. David Ibanez <j-david@noos.fr>\n"
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
361 "Language-Team: XX <python-dev@python.org>\n"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
362 "MIME-Version: 1.0\n"
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
363 "Content-Type: text/plain; charset=iso-8859-1\n"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
364 "Content-Transfer-Encoding: 8bit\n"
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
365 "Generated-By: pygettext.py 1.1\n"
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
366 "Plural-Forms: nplurals=2; plural=n!=1;\n"
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
367
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
368 #: test_gettext.py:19 test_gettext.py:25 test_gettext.py:31 test_gettext.py:37
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
369 #: test_gettext.py:51 test_gettext.py:80 test_gettext.py:86 test_gettext.py:92
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
370 #: test_gettext.py:98
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
371 msgid "nudge nudge"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
372 msgstr "wink wink"
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
373
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
374 #: test_gettext.py:16 test_gettext.py:22 test_gettext.py:28 test_gettext.py:34
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
375 #: test_gettext.py:77 test_gettext.py:83 test_gettext.py:89 test_gettext.py:95
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
376 msgid "albatross"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
377 msgstr ""
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
378
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
379 #: test_gettext.py:18 test_gettext.py:24 test_gettext.py:30 test_gettext.py:36
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
380 #: test_gettext.py:79 test_gettext.py:85 test_gettext.py:91 test_gettext.py:97
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
381 msgid "Raymond Luxury Yach-t"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
382 msgstr "Throatwobbler Mangrove"
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
383
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
384 #: test_gettext.py:17 test_gettext.py:23 test_gettext.py:29 test_gettext.py:35
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
385 #: test_gettext.py:56 test_gettext.py:78 test_gettext.py:84 test_gettext.py:90
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
386 #: test_gettext.py:96
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
387 msgid "mullusk"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
388 msgstr "bacon"
14191
bd3d1411b66c Set this test up so that we don't have to create xx/LC_MESSAGES in the
Barry Warsaw <barry@python.org>
parents: 14188
diff changeset
389
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
390 #: test_gettext.py:40 test_gettext.py:101
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
391 msgid ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
392 "This module provides internationalization and localization\n"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
393 "support for your Python programs by providing an interface to the GNU\n"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
394 "gettext message catalog library."
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
395 msgstr ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
396 "Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba\n"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
397 "fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH\n"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
398 "trggrkg zrffntr pngnybt yvoenel."
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
399
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
400 # Manually added, as neither pygettext nor xgettext support plural forms
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
401 # in Python.
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
402 msgid "There is %s file"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
403 msgid_plural "There are %s files"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
404 msgstr[0] "Hay %s fichero"
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
405 msgstr[1] "Hay %s ficheros"
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
406 '''
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
407
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
408 # Here's the second example po file example, used to generate the UMO_DATA
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
409 # containing utf-8 encoded Unicode strings
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
410
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
411 '''
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
412 # Dummy translation for the Python test_gettext.py module.
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
413 # Copyright (C) 2001 Python Software Foundation
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
414 # Barry Warsaw <barry@python.org>, 2000.
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
415 #
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
416 msgid ""
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
417 msgstr ""
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
418 "Project-Id-Version: 2.0\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
419 "PO-Revision-Date: 2003-04-11 12:42-0400\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
420 "Last-Translator: Barry A. WArsaw <barry@python.org>\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
421 "Language-Team: XX <python-dev@python.org>\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
422 "MIME-Version: 1.0\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
423 "Content-Type: text/plain; charset=utf-8\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
424 "Content-Transfer-Encoding: 7bit\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
425 "Generated-By: manually\n"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
426
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
427 #: nofile:0
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
428 msgid "ab\xc3\x9e"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
429 msgstr "\xc2\xa4yz"
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
430 '''
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
431
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
432 # Here's the third example po file, used to generate MMO_DATA
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
433
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
434 '''
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
435 msgid ""
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
436 msgstr ""
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
437 "Project-Id-Version: No Project 0.0\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
438 "POT-Creation-Date: Wed Dec 11 07:44:15 2002\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
439 "PO-Revision-Date: 2002-08-14 01:18:58+00:00\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
440 "Last-Translator: John Doe <jdoe@example.com>\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
441 "Jane Foobar <jfoobar@example.com>\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
442 "Language-Team: xx <xx@example.com>\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
443 "MIME-Version: 1.0\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
444 "Content-Type: text/plain; charset=iso-8859-15\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
445 "Content-Transfer-Encoding: quoted-printable\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
446 "Generated-By: pygettext.py 1.3\n"
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
447 '''