annotate babel/messages/tests/frontend.py @ 541:aa471d38bcde

fix a couple of frontend tests so they actually test something (fixes #260)
author fschwarz
date Wed, 16 Mar 2011 14:31:44 +0000
parents f627cb879dc3
children 59db0f962e00
rev   line source
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
2 #
530
85e1beadacb0 Update the copyright line.
jruigrok
parents: 521
diff changeset
3 # Copyright (C) 2007-2011 Edgewall Software
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
4 # All rights reserved.
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
5 #
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
9 #
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
13
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
14 from datetime import datetime
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
15 from distutils.dist import Distribution
372
129f3e4e6a7d Remove some unused imports.
palgarvio
parents: 371
diff changeset
16 from distutils.errors import DistutilsOptionError
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
17 from distutils.log import _global_log
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
18 import doctest
521
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
19 import logging
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
20 import os
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
21 import shutil
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
22 from StringIO import StringIO
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
23 import sys
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
24 import time
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
25 import unittest
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
26
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
27 from babel import __version__ as VERSION
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
28 from babel.dates import format_datetime
372
129f3e4e6a7d Remove some unused imports.
palgarvio
parents: 371
diff changeset
29 from babel.messages import frontend
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
30 from babel.util import LOCALTZ
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
31
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
32
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
33 class CompileCatalogTestCase(unittest.TestCase):
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
34
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
35 def setUp(self):
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
36 self.olddir = os.getcwd()
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
37 self.datadir = os.path.join(os.path.dirname(__file__), 'data')
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
38 os.chdir(self.datadir)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
39 _global_log.threshold = 5 # shut up distutils logging
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
40
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
41 self.dist = Distribution(dict(
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
42 name='TestProject',
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
43 version='0.1',
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
44 packages=['project']
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
45 ))
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
46 self.cmd = frontend.compile_catalog(self.dist)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
47 self.cmd.initialize_options()
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
48
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
49 def tearDown(self):
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
50 os.chdir(self.olddir)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
51
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
52 def test_no_directory_or_output_file_specified(self):
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
53 self.cmd.locale = 'en_US'
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
54 self.cmd.input_file = 'dummy'
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
55 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
56
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
57 def test_no_directory_or_input_file_specified(self):
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
58 self.cmd.locale = 'en_US'
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
59 self.cmd.output_file = 'dummy'
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
60 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
61
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
62
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
63 class ExtractMessagesTestCase(unittest.TestCase):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
64
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
65 def setUp(self):
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
66 self.olddir = os.getcwd()
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
67 self.datadir = os.path.join(os.path.dirname(__file__), 'data')
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
68 os.chdir(self.datadir)
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
69 _global_log.threshold = 5 # shut up distutils logging
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
70
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
71 self.dist = Distribution(dict(
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
72 name='TestProject',
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
73 version='0.1',
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
74 packages=['project']
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
75 ))
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
76 self.cmd = frontend.extract_messages(self.dist)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
77 self.cmd.initialize_options()
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
78
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
79 def tearDown(self):
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
80 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
81 if os.path.isfile(pot_file):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
82 os.unlink(pot_file)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
83
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
84 os.chdir(self.olddir)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
85
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
86 def test_neither_default_nor_custom_keywords(self):
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
87 self.cmd.output_file = 'dummy'
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
88 self.cmd.no_default_keywords = True
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
89 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
90
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
91 def test_no_output_file_specified(self):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
92 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
93
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
94 def test_both_sort_output_and_sort_by_file(self):
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
95 self.cmd.output_file = 'dummy'
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
96 self.cmd.sort_output = True
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
97 self.cmd.sort_by_file = True
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
98 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
99
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
100 def test_extraction_with_default_mapping(self):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
101 self.cmd.copyright_holder = 'FooBar, Inc.'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
102 self.cmd.msgid_bugs_address = 'bugs.address@email.tld'
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
103 self.cmd.output_file = 'project/i18n/temp.pot'
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
104 self.cmd.add_comments = 'TRANSLATOR:,TRANSLATORS:'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
105
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
106 self.cmd.finalize_options()
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
107 self.cmd.run()
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
108
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
109 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
110 assert os.path.isfile(pot_file)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
111
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
112 self.assertEqual(
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
113 r"""# Translations template for TestProject.
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
114 # Copyright (C) %(year)s FooBar, Inc.
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
115 # This file is distributed under the same license as the TestProject
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
116 # project.
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
117 # FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
118 #
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
119 #, fuzzy
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
120 msgid ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
121 msgstr ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
122 "Project-Id-Version: TestProject 0.1\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
123 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
124 "POT-Creation-Date: %(date)s\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
125 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
126 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
127 "Language-Team: LANGUAGE <LL@li.org>\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
128 "MIME-Version: 1.0\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
129 "Content-Type: text/plain; charset=utf-8\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
130 "Content-Transfer-Encoding: 8bit\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
131 "Generated-By: Babel %(version)s\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
132
338
6fe060286ff0 Stripping of comment tags is optional now. If enabled it will strip the tags from all lines of a comment now.
aronacher
parents: 335
diff changeset
133 #. TRANSLATOR: This will be a translator coment,
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
134 #. that will include several lines
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
135 #: project/file1.py:8
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
136 msgid "bar"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
137 msgstr ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
138
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
139 #: project/file2.py:9
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
140 msgid "foobar"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
141 msgid_plural "foobars"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
142 msgstr[0] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
143 msgstr[1] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
144
458
496679689e11 Rename the ''CVS'' directory in the test data to ''ignored'', as quite a number of tools are configured or even hardcoded to ignore CVS directories. For example, I couldn't find a way to include the directory in the sdist tarball.
cmlenz
parents: 424
diff changeset
145 #: project/ignored/this_wont_normally_be_here.py:11
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
146 msgid "FooBar"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
147 msgid_plural "FooBars"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
148 msgstr[0] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
149 msgstr[1] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
150
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
151 """ % {'version': VERSION,
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
152 'year': time.strftime('%Y'),
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
153 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
154 tzinfo=LOCALTZ, locale='en')},
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
155 open(pot_file, 'U').read())
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
156
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
157 def test_extraction_with_mapping_file(self):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
158 self.cmd.copyright_holder = 'FooBar, Inc.'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
159 self.cmd.msgid_bugs_address = 'bugs.address@email.tld'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
160 self.cmd.mapping_file = 'mapping.cfg'
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
161 self.cmd.output_file = 'project/i18n/temp.pot'
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
162 self.cmd.add_comments = 'TRANSLATOR:,TRANSLATORS:'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
163
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
164 self.cmd.finalize_options()
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
165 self.cmd.run()
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
166
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
167 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
168 assert os.path.isfile(pot_file)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
169
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
170 self.assertEqual(
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
171 r"""# Translations template for TestProject.
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
172 # Copyright (C) %(year)s FooBar, Inc.
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
173 # This file is distributed under the same license as the TestProject
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
174 # project.
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
175 # FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
176 #
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
177 #, fuzzy
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
178 msgid ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
179 msgstr ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
180 "Project-Id-Version: TestProject 0.1\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
181 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
182 "POT-Creation-Date: %(date)s\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
183 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
184 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
185 "Language-Team: LANGUAGE <LL@li.org>\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
186 "MIME-Version: 1.0\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
187 "Content-Type: text/plain; charset=utf-8\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
188 "Content-Transfer-Encoding: 8bit\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
189 "Generated-By: Babel %(version)s\n"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
190
338
6fe060286ff0 Stripping of comment tags is optional now. If enabled it will strip the tags from all lines of a comment now.
aronacher
parents: 335
diff changeset
191 #. TRANSLATOR: This will be a translator coment,
114
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
192 #. that will include several lines
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
193 #: project/file1.py:8
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
194 msgid "bar"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
195 msgstr ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
196
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
197 #: project/file2.py:9
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
198 msgid "foobar"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
199 msgid_plural "foobars"
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
200 msgstr[0] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
201 msgstr[1] ""
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
202
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
203 """ % {'version': VERSION,
5ec3364f250a Added some minor distutils frontend tests, corrected and moved mapping.cfg to the appropriate place.
palgarvio
parents: 54
diff changeset
204 'year': time.strftime('%Y'),
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
205 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
206 tzinfo=LOCALTZ, locale='en')},
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
207 open(pot_file, 'U').read())
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
208
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
209 def test_extraction_with_mapping_dict(self):
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
210 self.dist.message_extractors = {
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
211 'project': [
458
496679689e11 Rename the ''CVS'' directory in the test data to ''ignored'', as quite a number of tools are configured or even hardcoded to ignore CVS directories. For example, I couldn't find a way to include the directory in the sdist tarball.
cmlenz
parents: 424
diff changeset
212 ('**/ignored/**.*', 'ignore', None),
496679689e11 Rename the ''CVS'' directory in the test data to ''ignored'', as quite a number of tools are configured or even hardcoded to ignore CVS directories. For example, I couldn't find a way to include the directory in the sdist tarball.
cmlenz
parents: 424
diff changeset
213 ('**.py', 'python', None),
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
214 ]
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
215 }
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
216 self.cmd.copyright_holder = 'FooBar, Inc.'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
217 self.cmd.msgid_bugs_address = 'bugs.address@email.tld'
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
218 self.cmd.output_file = 'project/i18n/temp.pot'
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
219 self.cmd.add_comments = 'TRANSLATOR:,TRANSLATORS:'
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
220
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
221 self.cmd.finalize_options()
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
222 self.cmd.run()
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
223
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
224 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
225 assert os.path.isfile(pot_file)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
226
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
227 self.assertEqual(
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
228 r"""# Translations template for TestProject.
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
229 # Copyright (C) %(year)s FooBar, Inc.
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
230 # This file is distributed under the same license as the TestProject
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
231 # project.
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
232 # FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
233 #
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
234 #, fuzzy
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
235 msgid ""
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
236 msgstr ""
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
237 "Project-Id-Version: TestProject 0.1\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
238 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
239 "POT-Creation-Date: %(date)s\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
240 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
241 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
242 "Language-Team: LANGUAGE <LL@li.org>\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
243 "MIME-Version: 1.0\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
244 "Content-Type: text/plain; charset=utf-8\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
245 "Content-Transfer-Encoding: 8bit\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
246 "Generated-By: Babel %(version)s\n"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
247
338
6fe060286ff0 Stripping of comment tags is optional now. If enabled it will strip the tags from all lines of a comment now.
aronacher
parents: 335
diff changeset
248 #. TRANSLATOR: This will be a translator coment,
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
249 #. that will include several lines
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
250 #: project/file1.py:8
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
251 msgid "bar"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
252 msgstr ""
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
253
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
254 #: project/file2.py:9
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
255 msgid "foobar"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
256 msgid_plural "foobars"
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
257 msgstr[0] ""
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
258 msgstr[1] ""
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
259
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
260 """ % {'version': VERSION,
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
261 'year': time.strftime('%Y'),
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
262 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
263 tzinfo=LOCALTZ, locale='en')},
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
264 open(pot_file, 'U').read())
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
265
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
266
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 177
diff changeset
267 class InitCatalogTestCase(unittest.TestCase):
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
268
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
269 def setUp(self):
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
270 self.olddir = os.getcwd()
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
271 self.datadir = os.path.join(os.path.dirname(__file__), 'data')
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
272 os.chdir(self.datadir)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
273 _global_log.threshold = 5 # shut up distutils logging
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
274
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
275 self.dist = Distribution(dict(
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
276 name='TestProject',
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
277 version='0.1',
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
278 packages=['project']
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
279 ))
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 177
diff changeset
280 self.cmd = frontend.init_catalog(self.dist)
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
281 self.cmd.initialize_options()
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
282
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
283 def tearDown(self):
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
284 for dirname in ['en_US', 'ja_JP', 'lv_LV']:
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
285 locale_dir = os.path.join(self.datadir, 'project', 'i18n', dirname)
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
286 if os.path.isdir(locale_dir):
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
287 shutil.rmtree(locale_dir)
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
288
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
289 os.chdir(self.olddir)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
290
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
291 def test_no_input_file(self):
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
292 self.cmd.locale = 'en_US'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
293 self.cmd.output_file = 'dummy'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
294 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
295
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
296 def test_no_locale(self):
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
297 self.cmd.input_file = 'dummy'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
298 self.cmd.output_file = 'dummy'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
299 self.assertRaises(DistutilsOptionError, self.cmd.finalize_options)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
300
121
78a9033b6839 Fix parsing of timezone in POT creation date.
cmlenz
parents: 120
diff changeset
301 def test_with_output_dir(self):
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
302 self.cmd.input_file = 'project/i18n/messages.pot'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
303 self.cmd.locale = 'en_US'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
304 self.cmd.output_dir = 'project/i18n'
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
305
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
306 self.cmd.finalize_options()
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
307 self.cmd.run()
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
308
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
309 po_file = os.path.join(self.datadir, 'project', 'i18n', 'en_US',
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
310 'LC_MESSAGES', 'messages.po')
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
311 assert os.path.isfile(po_file)
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
312
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
313 self.assertEqual(
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
314 r"""# English (United States) translations for TestProject.
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
315 # Copyright (C) 2007 FooBar, Inc.
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
316 # This file is distributed under the same license as the TestProject
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
317 # project.
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
318 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
319 #
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
320 msgid ""
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
321 msgstr ""
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
322 "Project-Id-Version: TestProject 0.1\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
323 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
324 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
325 "PO-Revision-Date: %(date)s\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
326 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
327 "Language-Team: en_US <LL@li.org>\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
328 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
329 "MIME-Version: 1.0\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
330 "Content-Type: text/plain; charset=utf-8\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
331 "Content-Transfer-Encoding: 8bit\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
332 "Generated-By: Babel %(version)s\n"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
333
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
334 #. This will be a translator coment,
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
335 #. that will include several lines
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
336 #: project/file1.py:8
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
337 msgid "bar"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
338 msgstr ""
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
339
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
340 #: project/file2.py:9
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
341 msgid "foobar"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
342 msgid_plural "foobars"
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
343 msgstr[0] ""
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
344 msgstr[1] ""
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
345
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
346 """ % {'version': VERSION,
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
347 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
348 tzinfo=LOCALTZ, locale='en')},
120
733cca7ff6a5 Added tests for `new_catalog` distutils command.
cmlenz
parents: 117
diff changeset
349 open(po_file, 'U').read())
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
350
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
351 def test_keeps_catalog_non_fuzzy(self):
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
352 self.cmd.input_file = 'project/i18n/messages_non_fuzzy.pot'
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
353 self.cmd.locale = 'en_US'
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
354 self.cmd.output_dir = 'project/i18n'
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
355
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
356 self.cmd.finalize_options()
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
357 self.cmd.run()
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
358
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
359 po_file = os.path.join(self.datadir, 'project', 'i18n', 'en_US',
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
360 'LC_MESSAGES', 'messages.po')
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
361 assert os.path.isfile(po_file)
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
362
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
363 self.assertEqual(
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
364 r"""# English (United States) translations for TestProject.
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
365 # Copyright (C) 2007 FooBar, Inc.
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
366 # This file is distributed under the same license as the TestProject
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
367 # project.
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
368 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
369 #
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
370 msgid ""
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
371 msgstr ""
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
372 "Project-Id-Version: TestProject 0.1\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
373 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
374 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
375 "PO-Revision-Date: %(date)s\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
376 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
377 "Language-Team: en_US <LL@li.org>\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
378 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
379 "MIME-Version: 1.0\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
380 "Content-Type: text/plain; charset=utf-8\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
381 "Content-Transfer-Encoding: 8bit\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
382 "Generated-By: Babel %(version)s\n"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
383
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
384 #. This will be a translator coment,
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
385 #. that will include several lines
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
386 #: project/file1.py:8
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
387 msgid "bar"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
388 msgstr ""
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
389
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
390 #: project/file2.py:9
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
391 msgid "foobar"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
392 msgid_plural "foobars"
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
393 msgstr[0] ""
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
394 msgstr[1] ""
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
395
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
396 """ % {'version': VERSION,
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
397 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
398 tzinfo=LOCALTZ, locale='en')},
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
399 open(po_file, 'U').read())
370
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
400
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
401 def test_correct_init_more_than_2_plurals(self):
370
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
402 self.cmd.input_file = 'project/i18n/messages.pot'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
403 self.cmd.locale = 'lv_LV'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
404 self.cmd.output_dir = 'project/i18n'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
405
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
406 self.cmd.finalize_options()
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
407 self.cmd.run()
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
408
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
409 po_file = os.path.join(self.datadir, 'project', 'i18n', 'lv_LV',
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
410 'LC_MESSAGES', 'messages.po')
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
411 assert os.path.isfile(po_file)
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
412
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
413 self.assertEqual(
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
414 r"""# Latvian (Latvia) translations for TestProject.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
415 # Copyright (C) 2007 FooBar, Inc.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
416 # This file is distributed under the same license as the TestProject
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
417 # project.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
418 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
419 #
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
420 msgid ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
421 msgstr ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
422 "Project-Id-Version: TestProject 0.1\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
423 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
424 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
425 "PO-Revision-Date: %(date)s\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
426 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
427 "Language-Team: lv_LV <LL@li.org>\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
428 "Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
429 " 2)\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
430 "MIME-Version: 1.0\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
431 "Content-Type: text/plain; charset=utf-8\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
432 "Content-Transfer-Encoding: 8bit\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
433 "Generated-By: Babel %(version)s\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
434
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
435 #. This will be a translator coment,
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
436 #. that will include several lines
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
437 #: project/file1.py:8
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
438 msgid "bar"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
439 msgstr ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
440
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
441 #: project/file2.py:9
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
442 msgid "foobar"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
443 msgid_plural "foobars"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
444 msgstr[0] ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
445 msgstr[1] ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
446 msgstr[2] ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
447
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
448 """ % {'version': VERSION,
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
449 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
450 tzinfo=LOCALTZ, locale='en')},
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
451 open(po_file, 'U').read())
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
452
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
453 def test_correct_init_singular_plural_forms(self):
370
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
454 self.cmd.input_file = 'project/i18n/messages.pot'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
455 self.cmd.locale = 'ja_JP'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
456 self.cmd.output_dir = 'project/i18n'
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
457
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
458 self.cmd.finalize_options()
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
459 self.cmd.run()
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
460
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
461 po_file = os.path.join(self.datadir, 'project', 'i18n', 'ja_JP',
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
462 'LC_MESSAGES', 'messages.po')
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
463 assert os.path.isfile(po_file)
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
464
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
465 self.assertEqual(
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
466 r"""# Japanese (Japan) translations for TestProject.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
467 # Copyright (C) 2007 FooBar, Inc.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
468 # This file is distributed under the same license as the TestProject
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
469 # project.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
470 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
471 #
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
472 msgid ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
473 msgstr ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
474 "Project-Id-Version: TestProject 0.1\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
475 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
476 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
477 "PO-Revision-Date: %(date)s\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
478 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
479 "Language-Team: ja_JP <LL@li.org>\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
480 "Plural-Forms: nplurals=1; plural=0\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
481 "MIME-Version: 1.0\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
482 "Content-Type: text/plain; charset=utf-8\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
483 "Content-Transfer-Encoding: 8bit\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
484 "Generated-By: Babel %(version)s\n"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
485
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
486 #. This will be a translator coment,
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
487 #. that will include several lines
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
488 #: project/file1.py:8
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
489 msgid "bar"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
490 msgstr ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
491
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
492 #: project/file2.py:9
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
493 msgid "foobar"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
494 msgid_plural "foobars"
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
495 msgstr[0] ""
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
496
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
497 """ % {'version': VERSION,
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
498 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
499 tzinfo=LOCALTZ, locale='ja_JP')},
6129d2e770bc We no longer neglect `catalog.plurals`. Added tests for it. Fixes #120.
palgarvio
parents: 338
diff changeset
500 open(po_file, 'U').read())
115
9703a0ad56bd Added new logo.
cmlenz
parents: 114
diff changeset
501
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 177
diff changeset
502
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
503 class CommandLineInterfaceTestCase(unittest.TestCase):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
504
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
505 def setUp(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
506 self.datadir = os.path.join(os.path.dirname(__file__), 'data')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
507 self.orig_working_dir = os.getcwd()
128
7b807415c3ff Fake `sys.argv` for CLI tests.
cmlenz
parents: 127
diff changeset
508 self.orig_argv = sys.argv
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
509 self.orig_stdout = sys.stdout
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
510 self.orig_stderr = sys.stderr
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
511 sys.argv = ['pybabel']
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
512 sys.stdout = StringIO()
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
513 sys.stderr = StringIO()
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
514 os.chdir(self.datadir)
521
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
515
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
516 # Logging handlers will be reused if possible (#227). This breaks the
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
517 # implicit assumption that our newly created StringIO for sys.stderr
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
518 # contains the console output. Removing the old handler ensures that a
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
519 # new handler with our new StringIO instance will be used.
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
520 log = logging.getLogger('babel')
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
521 for handler in log.handlers:
36856816299a prevent !CommandLineInterface.run from accumulating logging handlers (fixes #227)
fschwarz
parents: 458
diff changeset
522 log.removeHandler(handler)
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
523 self.cli = frontend.CommandLineInterface()
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
524
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
525 def tearDown(self):
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
526 os.chdir(self.orig_working_dir)
128
7b807415c3ff Fake `sys.argv` for CLI tests.
cmlenz
parents: 127
diff changeset
527 sys.argv = self.orig_argv
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
528 sys.stdout = self.orig_stdout
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
529 sys.stderr = self.orig_stderr
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
530 for dirname in ['lv_LV', 'ja_JP']:
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
531 locale_dir = os.path.join(self.datadir, 'project', 'i18n', dirname)
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
532 if os.path.isdir(locale_dir):
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
533 shutil.rmtree(locale_dir)
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
534
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
535 def test_usage(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
536 try:
128
7b807415c3ff Fake `sys.argv` for CLI tests.
cmlenz
parents: 127
diff changeset
537 self.cli.run(sys.argv)
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
538 self.fail('Expected SystemExit')
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
539 except SystemExit, e:
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
540 self.assertEqual(2, e.code)
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
541 self.assertEqual("""\
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
542 usage: pybabel command [options] [args]
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
543
424
6f86eb8f54ce Use a more explicit error message if no option or argument(command) is passed to `pybabel`. Fixes #81.
palgarvio
parents: 372
diff changeset
544 pybabel: error: no valid command or option passed. try the -h/--help option for more information.
135
f22177653f86 Fix frontend tests on Python 2.5, where the case of some of the output of optparse usage has changed.
cmlenz
parents: 134
diff changeset
545 """, sys.stderr.getvalue().lower())
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
546
539
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
547 def _run_init_catalog(self):
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
548 i18n_dir = os.path.join(self.datadir, 'project', 'i18n')
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
549 pot_path = os.path.join(self.datadir, 'project', 'i18n', 'messages.pot')
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
550 init_argv = sys.argv + ['init', '--locale', 'en_US', '-d', i18n_dir,
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
551 '-i', pot_path]
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
552 self.cli.run(init_argv)
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
553
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
554 def test_no_duplicated_output_for_multiple_runs(self):
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
555 self._run_init_catalog()
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
556 first_output = sys.stderr.getvalue()
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
557 self._run_init_catalog()
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
558 second_output = sys.stderr.getvalue()[len(first_output):]
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
559
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
560 # in case the log message is not duplicated we should get the same
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
561 # output as before
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
562 self.assertEqual(first_output, second_output)
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
563
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
564 def test_frontend_can_log_to_predefined_handler(self):
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
565 custom_stream = StringIO()
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
566 log = logging.getLogger('babel')
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
567 log.addHandler(logging.StreamHandler(custom_stream))
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
568
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
569 self._run_init_catalog()
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
570 self.assertNotEqual(id(sys.stderr), id(custom_stream))
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
571 self.assertEqual('', sys.stderr.getvalue())
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
572 assert len(custom_stream.getvalue()) > 0
f627cb879dc3 add actual unit tests for #227 and add missing changelog entry
fschwarz
parents: 530
diff changeset
573
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
574 def test_help(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
575 try:
128
7b807415c3ff Fake `sys.argv` for CLI tests.
cmlenz
parents: 127
diff changeset
576 self.cli.run(sys.argv + ['--help'])
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
577 self.fail('Expected SystemExit')
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
578 except SystemExit, e:
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
579 self.assertEqual(0, e.code)
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
580 self.assertEqual("""\
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
581 usage: pybabel command [options] [args]
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
582
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
583 options:
185
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
584 --version show program's version number and exit
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
585 -h, --help show this help message and exit
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
586 --list-locales print all known locales and exit
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
587 -v, --verbose print as much as possible
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
588 -q, --quiet print as little as possible
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
589
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
590 commands:
185
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
591 compile compile message catalogs to mo files
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
592 extract extract messages from source files and generate a pot file
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
593 init create new message catalogs from a pot file
170cffc66554 Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents: 181
diff changeset
594 update update existing message catalogs from a pot file
135
f22177653f86 Fix frontend tests on Python 2.5, where the case of some of the output of optparse usage has changed.
cmlenz
parents: 134
diff changeset
595 """, sys.stdout.getvalue().lower())
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
596
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
597 def test_extract_with_default_mapping(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
598 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
599 self.cli.run(sys.argv + ['extract',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
600 '--copyright-holder', 'FooBar, Inc.',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
601 '--project', 'TestProject', '--version', '0.1',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
602 '--msgid-bugs-address', 'bugs.address@email.tld',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
603 '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
604 '-o', pot_file, 'project'])
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
605 assert os.path.isfile(pot_file)
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
606 self.assertEqual(
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
607 r"""# Translations template for TestProject.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
608 # Copyright (C) %(year)s FooBar, Inc.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
609 # This file is distributed under the same license as the TestProject
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
610 # project.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
611 # FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
612 #
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
613 #, fuzzy
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
614 msgid ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
615 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
616 "Project-Id-Version: TestProject 0.1\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
617 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
618 "POT-Creation-Date: %(date)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
619 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
620 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
621 "Language-Team: LANGUAGE <LL@li.org>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
622 "MIME-Version: 1.0\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
623 "Content-Type: text/plain; charset=utf-8\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
624 "Content-Transfer-Encoding: 8bit\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
625 "Generated-By: Babel %(version)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
626
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
627 #. TRANSLATOR: This will be a translator coment,
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
628 #. that will include several lines
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
629 #: project/file1.py:8
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
630 msgid "bar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
631 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
632
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
633 #: project/file2.py:9
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
634 msgid "foobar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
635 msgid_plural "foobars"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
636 msgstr[0] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
637 msgstr[1] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
638
458
496679689e11 Rename the ''CVS'' directory in the test data to ''ignored'', as quite a number of tools are configured or even hardcoded to ignore CVS directories. For example, I couldn't find a way to include the directory in the sdist tarball.
cmlenz
parents: 424
diff changeset
639 #: project/ignored/this_wont_normally_be_here.py:11
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
640 msgid "FooBar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
641 msgid_plural "FooBars"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
642 msgstr[0] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
643 msgstr[1] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
644
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
645 """ % {'version': VERSION,
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
646 'year': time.strftime('%Y'),
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
647 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
648 tzinfo=LOCALTZ, locale='en')},
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
649 open(pot_file, 'U').read())
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
650
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
651 def test_extract_with_mapping_file(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
652 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
653 self.cli.run(sys.argv + ['extract',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
654 '--copyright-holder', 'FooBar, Inc.',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
655 '--project', 'TestProject', '--version', '0.1',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
656 '--msgid-bugs-address', 'bugs.address@email.tld',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
657 '--mapping', os.path.join(self.datadir, 'mapping.cfg'),
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
658 '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
659 '-o', pot_file, 'project'])
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
660 assert os.path.isfile(pot_file)
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
661 self.assertEqual(
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
662 r"""# Translations template for TestProject.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
663 # Copyright (C) %(year)s FooBar, Inc.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
664 # This file is distributed under the same license as the TestProject
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
665 # project.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
666 # FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
667 #
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
668 #, fuzzy
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
669 msgid ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
670 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
671 "Project-Id-Version: TestProject 0.1\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
672 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
673 "POT-Creation-Date: %(date)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
674 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
675 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
676 "Language-Team: LANGUAGE <LL@li.org>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
677 "MIME-Version: 1.0\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
678 "Content-Type: text/plain; charset=utf-8\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
679 "Content-Transfer-Encoding: 8bit\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
680 "Generated-By: Babel %(version)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
681
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
682 #. TRANSLATOR: This will be a translator coment,
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
683 #. that will include several lines
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
684 #: project/file1.py:8
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
685 msgid "bar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
686 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
687
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
688 #: project/file2.py:9
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
689 msgid "foobar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
690 msgid_plural "foobars"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
691 msgstr[0] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
692 msgstr[1] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
693
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
694 """ % {'version': VERSION,
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
695 'year': time.strftime('%Y'),
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
696 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
697 tzinfo=LOCALTZ, locale='en')},
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
698 open(pot_file, 'U').read())
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
699
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
700 def test_init_with_output_dir(self):
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
701 po_file = os.path.join(self.datadir, 'project', 'i18n', 'en_US',
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
702 'LC_MESSAGES', 'messages.po')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
703 self.cli.run(sys.argv + ['init',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
704 '--locale', 'en_US',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
705 '-d', os.path.join(self.datadir, 'project', 'i18n'),
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
706 '-i', os.path.join(self.datadir, 'project', 'i18n', 'messages.pot')])
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
707 assert os.path.isfile(po_file)
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
708 self.assertEqual(
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
709 r"""# English (United States) translations for TestProject.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
710 # Copyright (C) 2007 FooBar, Inc.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
711 # This file is distributed under the same license as the TestProject
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
712 # project.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
713 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
714 #
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
715 #, fuzzy
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
716 msgid ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
717 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
718 "Project-Id-Version: TestProject 0.1\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
719 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
720 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
721 "PO-Revision-Date: %(date)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
722 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
723 "Language-Team: en_US <LL@li.org>\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
724 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
725 "MIME-Version: 1.0\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
726 "Content-Type: text/plain; charset=utf-8\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
727 "Content-Transfer-Encoding: 8bit\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
728 "Generated-By: Babel %(version)s\n"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
729
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
730 #. This will be a translator coment,
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
731 #. that will include several lines
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
732 #: project/file1.py:8
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
733 msgid "bar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
734 msgstr ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
735
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
736 #: project/file2.py:9
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
737 msgid "foobar"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
738 msgid_plural "foobars"
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
739 msgstr[0] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
740 msgstr[1] ""
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
741
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
742 """ % {'version': VERSION,
134
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
743 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
60565dc8495d More fixes for Windows compatibility:
cmlenz
parents: 128
diff changeset
744 tzinfo=LOCALTZ, locale='en')},
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
745 open(po_file, 'U').read())
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
746
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
747 def test_init_singular_plural_forms(self):
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
748 po_file = os.path.join(self.datadir, 'project', 'i18n', 'ja_JP',
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
749 'LC_MESSAGES', 'messages.po')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
750 self.cli.run(sys.argv + ['init',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
751 '--locale', 'ja_JP',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
752 '-d', os.path.join(self.datadir, 'project', 'i18n'),
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
753 '-i', os.path.join(self.datadir, 'project', 'i18n',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
754 'messages.pot')])
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
755 assert os.path.isfile(po_file)
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
756 self.assertEqual(
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
757 r"""# Japanese (Japan) translations for TestProject.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
758 # Copyright (C) 2007 FooBar, Inc.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
759 # This file is distributed under the same license as the TestProject
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
760 # project.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
761 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
762 #
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
763 #, fuzzy
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
764 msgid ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
765 msgstr ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
766 "Project-Id-Version: TestProject 0.1\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
767 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
768 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
769 "PO-Revision-Date: %(date)s\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
770 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
771 "Language-Team: ja_JP <LL@li.org>\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
772 "Plural-Forms: nplurals=1; plural=0\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
773 "MIME-Version: 1.0\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
774 "Content-Type: text/plain; charset=utf-8\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
775 "Content-Transfer-Encoding: 8bit\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
776 "Generated-By: Babel %(version)s\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
777
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
778 #. This will be a translator coment,
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
779 #. that will include several lines
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
780 #: project/file1.py:8
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
781 msgid "bar"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
782 msgstr ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
783
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
784 #: project/file2.py:9
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
785 msgid "foobar"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
786 msgid_plural "foobars"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
787 msgstr[0] ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
788
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
789 """ % {'version': VERSION,
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
790 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
791 tzinfo=LOCALTZ, locale='en')},
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
792 open(po_file, 'U').read())
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
793
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
794 def test_init_more_than_2_plural_forms(self):
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
795 po_file = os.path.join(self.datadir, 'project', 'i18n', 'lv_LV',
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
796 'LC_MESSAGES', 'messages.po')
541
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
797 self.cli.run(sys.argv + ['init',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
798 '--locale', 'lv_LV',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
799 '-d', os.path.join(self.datadir, 'project', 'i18n'),
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
800 '-i', os.path.join(self.datadir, 'project', 'i18n',
aa471d38bcde fix a couple of frontend tests so they actually test something (fixes #260)
fschwarz
parents: 539
diff changeset
801 'messages.pot')])
371
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
802 assert os.path.isfile(po_file)
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
803 self.assertEqual(
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
804 r"""# Latvian (Latvia) translations for TestProject.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
805 # Copyright (C) 2007 FooBar, Inc.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
806 # This file is distributed under the same license as the TestProject
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
807 # project.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
808 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
809 #
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
810 #, fuzzy
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
811 msgid ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
812 msgstr ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
813 "Project-Id-Version: TestProject 0.1\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
814 "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
815 "POT-Creation-Date: 2007-04-01 15:30+0200\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
816 "PO-Revision-Date: %(date)s\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
817 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
818 "Language-Team: lv_LV <LL@li.org>\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
819 "Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
820 " 2)\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
821 "MIME-Version: 1.0\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
822 "Content-Type: text/plain; charset=utf-8\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
823 "Content-Transfer-Encoding: 8bit\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
824 "Generated-By: Babel %(version)s\n"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
825
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
826 #. This will be a translator coment,
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
827 #. that will include several lines
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
828 #: project/file1.py:8
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
829 msgid "bar"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
830 msgstr ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
831
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
832 #: project/file2.py:9
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
833 msgid "foobar"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
834 msgid_plural "foobars"
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
835 msgstr[0] ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
836 msgstr[1] ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
837 msgstr[2] ""
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
838
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
839 """ % {'version': VERSION,
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
840 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
841 tzinfo=LOCALTZ, locale='en')},
ffde26d66af1 Include fix of [407] in `pybabel`.
palgarvio
parents: 370
diff changeset
842 open(po_file, 'U').read())
177
a7766f92f944 * Instead of an extra `compile-all` option on the `compile` (or `compile_catalog`) command, compilation of all catalogs is performed when neither an `input_file` nor a `locale` is specified.
cmlenz
parents: 176
diff changeset
843
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
844 def test_compile_catalog(self):
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
845 po_file = os.path.join(self.datadir, 'project', 'i18n', 'de_DE',
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
846 'LC_MESSAGES', 'messages.po')
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
847 mo_file = po_file.replace('.po', '.mo')
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
848 self.cli.run(sys.argv + ['compile',
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
849 '--locale', 'de_DE',
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
850 '-d', os.path.join(self.datadir, 'project', 'i18n')])
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
851 assert not os.path.isfile(mo_file), 'Expected no file at %r' % mo_file
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
852 self.assertEqual("""\
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
853 catalog %r is marked as fuzzy, skipping
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
854 """ % (po_file), sys.stderr.getvalue())
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
855
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
856 def test_compile_fuzzy_catalog(self):
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
857 po_file = os.path.join(self.datadir, 'project', 'i18n', 'de_DE',
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
858 'LC_MESSAGES', 'messages.po')
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
859 mo_file = po_file.replace('.po', '.mo')
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
860 try:
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
861 self.cli.run(sys.argv + ['compile',
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
862 '--locale', 'de_DE', '--use-fuzzy',
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
863 '-d', os.path.join(self.datadir, 'project', 'i18n')])
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
864 assert os.path.isfile(mo_file)
176
c31a7948bb8e Added tests for the `compile` command of `babel` binary and `messages_non_fuzzy.pot` to further test `read_po` fuzzy bit header parsing.
palgarvio
parents: 171
diff changeset
865 self.assertEqual("""\
177
a7766f92f944 * Instead of an extra `compile-all` option on the `compile` (or `compile_catalog`) command, compilation of all catalogs is performed when neither an `input_file` nor a `locale` is specified.
cmlenz
parents: 176
diff changeset
866 compiling catalog %r to %r
232
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
867 """ % (po_file, mo_file), sys.stderr.getvalue())
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
868 finally:
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
869 if os.path.isfile(mo_file):
0e5c33776833 Use logging module for output from CLI frontend.
cmlenz
parents: 185
diff changeset
870 os.unlink(mo_file)
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
871
331
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
872 def test_compile_catalog_with_more_than_2_plural_forms(self):
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
873 po_file = os.path.join(self.datadir, 'project', 'i18n', 'ru_RU',
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
874 'LC_MESSAGES', 'messages.po')
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
875 mo_file = po_file.replace('.po', '.mo')
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
876 try:
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
877 self.cli.run(sys.argv + ['compile',
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
878 '--locale', 'ru_RU', '--use-fuzzy',
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
879 '-d', os.path.join(self.datadir, 'project', 'i18n')])
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
880 assert os.path.isfile(mo_file)
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
881 self.assertEqual("""\
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
882 compiling catalog %r to %r
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
883 """ % (po_file, mo_file), sys.stderr.getvalue())
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
884 finally:
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
885 if os.path.isfile(mo_file):
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
886 os.unlink(mo_file)
aa3a4c57511e Fix message catalog compilation for locales with more than two plural forms. Closes #95. Many thanks to Victor Safronovich for the patch.
cmlenz
parents: 251
diff changeset
887
177
a7766f92f944 * Instead of an extra `compile-all` option on the `compile` (or `compile_catalog`) command, compilation of all catalogs is performed when neither an `input_file` nor a `locale` is specified.
cmlenz
parents: 176
diff changeset
888
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
889 def suite():
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
890 suite = unittest.TestSuite()
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
891 suite.addTest(doctest.DocTestSuite(frontend))
160
80e51aabc440 Add MO file generation. Closes #21.
cmlenz
parents: 135
diff changeset
892 suite.addTest(unittest.makeSuite(CompileCatalogTestCase))
117
41506e62701f Made new frontend tests more ''unit-y'', i.e. calling the APIs directly instead of launching the scripts.
cmlenz
parents: 115
diff changeset
893 suite.addTest(unittest.makeSuite(ExtractMessagesTestCase))
181
9a1acb41e7dd The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
cmlenz
parents: 177
diff changeset
894 suite.addTest(unittest.makeSuite(InitCatalogTestCase))
127
0f3a08b1c7ae Add a couple of CLI tests.
cmlenz
parents: 121
diff changeset
895 suite.addTest(unittest.makeSuite(CommandLineInterfaceTestCase))
12
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
896 return suite
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
897
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
898 if __name__ == '__main__':
a2c54ef107c2 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
diff changeset
899 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software