Mercurial > babel > old > mirror
comparison babel/messages/tests/frontend.py @ 183:e927dffc9ab4
The frontends now provide ways to update existing translations catalogs from a template. Closes #22.
author | cmlenz |
---|---|
date | Thu, 28 Jun 2007 10:28:25 +0000 |
parents | 6138ea7ef7a8 |
children | d3bde66ac8a9 |
comparison
equal
deleted
inserted
replaced
181:5c85c0ec4ef8 | 183:e927dffc9ab4 |
---|---|
261 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', | 261 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', |
262 tzinfo=LOCALTZ, locale='en')}, | 262 tzinfo=LOCALTZ, locale='en')}, |
263 open(pot_file, 'U').read()) | 263 open(pot_file, 'U').read()) |
264 | 264 |
265 | 265 |
266 class NewCatalogTestCase(unittest.TestCase): | 266 class InitCatalogTestCase(unittest.TestCase): |
267 | 267 |
268 def setUp(self): | 268 def setUp(self): |
269 self.olddir = os.getcwd() | 269 self.olddir = os.getcwd() |
270 self.datadir = os.path.join(os.path.dirname(__file__), 'data') | 270 self.datadir = os.path.join(os.path.dirname(__file__), 'data') |
271 os.chdir(self.datadir) | 271 os.chdir(self.datadir) |
274 self.dist = Distribution(dict( | 274 self.dist = Distribution(dict( |
275 name='TestProject', | 275 name='TestProject', |
276 version='0.1', | 276 version='0.1', |
277 packages=['project'] | 277 packages=['project'] |
278 )) | 278 )) |
279 self.cmd = frontend.new_catalog(self.dist) | 279 self.cmd = frontend.init_catalog(self.dist) |
280 self.cmd.initialize_options() | 280 self.cmd.initialize_options() |
281 | 281 |
282 def tearDown(self): | 282 def tearDown(self): |
283 locale_dir = os.path.join(self.datadir, 'project', 'i18n', 'en_US') | 283 locale_dir = os.path.join(self.datadir, 'project', 'i18n', 'en_US') |
284 if os.path.isdir(locale_dir): | 284 if os.path.isdir(locale_dir): |
345 """ % {'version': VERSION, | 345 """ % {'version': VERSION, |
346 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', | 346 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', |
347 tzinfo=LOCALTZ, locale='en')}, | 347 tzinfo=LOCALTZ, locale='en')}, |
348 open(po_file, 'U').read()) | 348 open(po_file, 'U').read()) |
349 | 349 |
350 class NewNonFuzzyCatalogTestCase(unittest.TestCase): | 350 |
351 class InitCatalogNonFuzzyTestCase(unittest.TestCase): | |
352 # FIXME: what is this test case about? | |
351 | 353 |
352 def setUp(self): | 354 def setUp(self): |
353 self.olddir = os.getcwd() | 355 self.olddir = os.getcwd() |
354 self.datadir = os.path.join(os.path.dirname(__file__), 'data') | 356 self.datadir = os.path.join(os.path.dirname(__file__), 'data') |
355 os.chdir(self.datadir) | 357 os.chdir(self.datadir) |
358 self.dist = Distribution(dict( | 360 self.dist = Distribution(dict( |
359 name='TestProject', | 361 name='TestProject', |
360 version='0.1', | 362 version='0.1', |
361 packages=['project'] | 363 packages=['project'] |
362 )) | 364 )) |
363 self.cmd = frontend.new_catalog(self.dist) | 365 self.cmd = frontend.init_catalog(self.dist) |
364 self.cmd.initialize_options() | 366 self.cmd.initialize_options() |
365 | 367 |
366 def tearDown(self): | 368 def tearDown(self): |
367 locale_dir = os.path.join(self.datadir, 'project', 'i18n', 'en_US') | 369 locale_dir = os.path.join(self.datadir, 'project', 'i18n', 'en_US') |
368 if os.path.isdir(locale_dir): | 370 if os.path.isdir(locale_dir): |
417 | 419 |
418 """ % {'version': VERSION, | 420 """ % {'version': VERSION, |
419 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', | 421 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', |
420 tzinfo=LOCALTZ, locale='en')}, | 422 tzinfo=LOCALTZ, locale='en')}, |
421 open(po_file, 'U').read()) | 423 open(po_file, 'U').read()) |
424 | |
422 | 425 |
423 class CommandLineInterfaceTestCase(unittest.TestCase): | 426 class CommandLineInterfaceTestCase(unittest.TestCase): |
424 | 427 |
425 def setUp(self): | 428 def setUp(self): |
426 self.datadir = os.path.join(os.path.dirname(__file__), 'data') | 429 self.datadir = os.path.join(os.path.dirname(__file__), 'data') |
463 -h, --help show this help message and exit | 466 -h, --help show this help message and exit |
464 | 467 |
465 commands: | 468 commands: |
466 compile compile message catalogs to mo files | 469 compile compile message catalogs to mo files |
467 extract extract messages from source files and generate a pot file | 470 extract extract messages from source files and generate a pot file |
468 init create new message catalogs from a template | 471 init create new message catalogs from a pot file |
472 update update existing message catalogs from a pot file | |
469 """, sys.stdout.getvalue().lower()) | 473 """, sys.stdout.getvalue().lower()) |
470 | 474 |
471 def test_extract_with_default_mapping(self): | 475 def test_extract_with_default_mapping(self): |
472 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot') | 476 pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot') |
473 try: | 477 try: |
681 def suite(): | 685 def suite(): |
682 suite = unittest.TestSuite() | 686 suite = unittest.TestSuite() |
683 suite.addTest(doctest.DocTestSuite(frontend)) | 687 suite.addTest(doctest.DocTestSuite(frontend)) |
684 suite.addTest(unittest.makeSuite(CompileCatalogTestCase)) | 688 suite.addTest(unittest.makeSuite(CompileCatalogTestCase)) |
685 suite.addTest(unittest.makeSuite(ExtractMessagesTestCase)) | 689 suite.addTest(unittest.makeSuite(ExtractMessagesTestCase)) |
686 suite.addTest(unittest.makeSuite(NewCatalogTestCase)) | 690 suite.addTest(unittest.makeSuite(InitCatalogTestCase)) |
691 suite.addTest(unittest.makeSuite(InitCatalogNonFuzzyTestCase)) | |
687 suite.addTest(unittest.makeSuite(CommandLineInterfaceTestCase)) | 692 suite.addTest(unittest.makeSuite(CommandLineInterfaceTestCase)) |
688 return suite | 693 return suite |
689 | 694 |
690 if __name__ == '__main__': | 695 if __name__ == '__main__': |
691 unittest.main(defaultTest='suite') | 696 unittest.main(defaultTest='suite') |