annotate babel/messages/tests/frontend.py @ 605:6dc7e067bafc trunk

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