annotate Lib/test/test_gettext.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 85542715a249
children 6768b2350c57
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')
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
61
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
62
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
63 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
64 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
65 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
66 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
67 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
68 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
69 fp.close()
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
70 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
71 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
72 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
73 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
74 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
75 fp.close()
53644
85542715a249 Make test.test_support.EnvironmentVarGuard behave like a dictionary.
Walter Dörwald <walter@livinglogic.de>
parents: 41554
diff changeset
76 self.env = test_support.EnvironmentVarGuard()
85542715a249 Make test.test_support.EnvironmentVarGuard behave like a dictionary.
Walter Dörwald <walter@livinglogic.de>
parents: 41554
diff changeset
77 self.env['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
78
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
79 def tearDown(self):
53644
85542715a249 Make test.test_support.EnvironmentVarGuard behave like a dictionary.
Walter Dörwald <walter@livinglogic.de>
parents: 41554
diff changeset
80 self.env.__exit__()
85542715a249 Make test.test_support.EnvironmentVarGuard behave like a dictionary.
Walter Dörwald <walter@livinglogic.de>
parents: 41554
diff changeset
81 del self.env
28867
1a0b7fc4625b Make tests clean up after themselves better. This means:
Brett Cannon <bcannon@gmail.com>
parents: 28794
diff changeset
82 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
83
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
84
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
85 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
86 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
87 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
88 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
89 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
90 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
91
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
92 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
93 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
94 # 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
95 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
96 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
97 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
98 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
99
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
100 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
101 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
102 # 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
103 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
104 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
105 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
106 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
107
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
108 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
109 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
110 # 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
111 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
112 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
113 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
114 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
115
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
116 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
117 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
118 # 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
119 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
120 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
121 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
122 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
123
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
124 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
125 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
126 # 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
127 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
128 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
129 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
130 '''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
131 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
132 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
133
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
134 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
135 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
136 # 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
137 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
138 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
139 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
140 # 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
141 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
142 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
143 # 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
144 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
145 eq(_('mullusk'), 'bacon')
36593
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
146 # Test installation of other methods
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
147 import __builtin__
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
148 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
149 eq(_, t.ugettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
150 eq(__builtin__.gettext, t.ugettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
151 eq(lgettext, t.lgettext)
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
152 del __builtin__.gettext
bd7f2d8e8dea Patch #1349274: gettext.install() now optionally installs additional
Georg Brandl <georg@python.org>
parents: 32751
diff changeset
153 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
154
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
155
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
156 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
157 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
158 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
159 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
160 # 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
161 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
162 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
163 # For convenience
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
164 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
165
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
166 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
167 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
168
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
169 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
170 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
171
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
172 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
173 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
174 # 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
175 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
176 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
177 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
178 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
179
26327
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
180 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
181 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
182 # 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
183 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
184 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
185 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
186 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
187
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
188 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
189 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
190 # 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
191 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
192 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
193 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
194 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
195
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
196 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
197 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
198 # 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
199 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
200 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
201 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
202 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
203
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
204 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
205 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
206 # 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
207 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
208 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
209 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
210 '''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
211 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
212 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
213
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
214
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
215 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
216 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
217 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
218 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
219
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
220 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
221 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
222 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
223 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
224 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
225 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
226
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
237 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
238 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
239 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
240 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
241 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
242
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
243 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
244 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
245 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
246 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
247 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
248
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
249 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
250 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
251 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
252 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
253 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
254
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
255 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
256 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
257 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
258 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
259 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
260
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
261 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
262 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
263 # 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
264 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
265 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
266 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
267
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
268 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
269 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
270 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
271 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
272 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
273
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
274 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
275 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
276 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
277 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
278 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
279
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
280 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
281 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
282 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
283 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
284 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
285
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
286 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
287 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
288 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
289 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
290 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
291
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
292 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
293 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
294 # 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
295 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
296
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
297
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
298 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
299 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
300 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
301 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
302 try:
28794
05e57388cb8f UnicodeTranslationsTest.setUp(): Removed the coerce flag to the
Barry Warsaw <barry@python.org>
parents: 28774
diff changeset
303 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
304 finally:
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
305 fp.close()
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
306 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
307
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
308 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
309 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
310 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
311 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
312
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
313 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
314 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
315 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
316
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
317
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
318 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
319 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
320 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
321 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
322 try:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
323 try:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
324 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
325 except:
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.tearDown()
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
327 raise
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
328 finally:
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
329 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
330
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
331 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
332 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
333 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
334 '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
335
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
336
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
337 def test_main():
41554
06145fbc7ab9 Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 36593
diff changeset
338 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
339
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
340 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
341 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
342
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
343
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
344 # 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
345 #
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
346 # 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
347 # 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
348
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
349 '''
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
350 # 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
351 # 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
352 # 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
353 #
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
354 msgid ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
355 msgstr ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
356 "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
357 "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
358 "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
359 "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
360 "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
361 "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
362 "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
363 "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
364 "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
365
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
366 #: 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
367 #: 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
368 #: 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
369 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
370 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
371
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
372 #: 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
373 #: 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
374 msgid "albatross"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
375 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
376
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
377 #: 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
378 #: 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
379 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
380 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
381
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
382 #: 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
383 #: 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
384 #: 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
385 msgid "mullusk"
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
386 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
387
14258
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
388 #: 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
389 msgid ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
390 "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
391 "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
392 "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
393 msgstr ""
6396529a421c Expand the test suite to test both the GNU gettext and translation
Barry Warsaw <barry@python.org>
parents: 14224
diff changeset
394 "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
395 "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
396 "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
397
ea1d2050d7da Patch #633547: Support plural forms. Do TODOs in test suite.
Martin v. Löwis <martin@v.loewis.de>
parents: 24338
diff changeset
398 # 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
399 # 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
400 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
401 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
402 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
403 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
404 '''
28582
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
405
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
406 # 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
407 # 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
408
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
409 '''
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
410 # 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
411 # 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
412 # 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
413 #
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
414 msgid ""
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
415 msgstr ""
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
416 "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
417 "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
418 "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
419 "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
420 "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
421 "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
422 "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
423 "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
424
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
425 #: nofile:0
03bb0c408d57 From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
Barry Warsaw <barry@python.org>
parents: 26327
diff changeset
426 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
427 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
428 '''
29191
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
429
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
430 # 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
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 '''
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
433 msgid ""
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
434 msgstr ""
1297d405155b Added a test for the fix of SF bug #658233, where continuation lines
Barry Warsaw <barry@python.org>
parents: 28867
diff changeset
435 "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
436 "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
437 "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
438 "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
439 "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
440 "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
441 "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
442 "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
443 "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
444 "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
445 '''