Mercurial > babel > old > mirror
comparison 0.9.x/babel/messages/tests/frontend.py @ 542:3c4e1592e40a stable
merge r591 from trunk
author | fschwarz |
---|---|
date | Fri, 11 Mar 2011 16:49:45 +0000 |
parents | 22ad1d9936e7 |
children | 1e1bcb890af1 |
comparison
equal
deleted
inserted
replaced
540:b6530ed8e41f | 542:3c4e1592e40a |
---|---|
546 usage: pybabel command [options] [args] | 546 usage: pybabel command [options] [args] |
547 | 547 |
548 pybabel: error: no valid command or option passed. try the -h/--help option for more information. | 548 pybabel: error: no valid command or option passed. try the -h/--help option for more information. |
549 """, stderr.lower()) | 549 """, stderr.lower()) |
550 | 550 |
551 def _run_init_catalog(self): | |
552 i18n_dir = os.path.join(self.datadir, 'project', 'i18n') | |
553 pot_path = os.path.join(self.datadir, 'project', 'i18n', 'messages.pot') | |
554 init_argv = sys.argv + ['init', '--locale', 'en_US', '-d', i18n_dir, | |
555 '-i', pot_path] | |
556 self.cli.run(init_argv) | |
557 | |
558 def test_no_duplicated_output_for_multiple_runs(self): | |
559 self._run_init_catalog() | |
560 first_output = sys.stderr.getvalue() | |
561 self._run_init_catalog() | |
562 second_output = sys.stderr.getvalue()[len(first_output):] | |
563 | |
564 # in case the log message is not duplicated we should get the same | |
565 # output as before | |
566 self.assertEqual(first_output, second_output) | |
567 | |
568 def test_frontend_can_log_to_predefined_handler(self): | |
569 custom_stream = StringIO() | |
570 log = logging.getLogger('babel') | |
571 log.addHandler(logging.StreamHandler(custom_stream)) | |
572 | |
573 self._run_init_catalog() | |
574 self.assertNotEqual(id(sys.stderr), id(custom_stream)) | |
575 self.assertEqual('', sys.stderr.getvalue()) | |
576 assert len(custom_stream.getvalue()) > 0 | |
577 | |
551 def test_help(self): | 578 def test_help(self): |
552 try: | 579 try: |
553 self.cli.run(sys.argv + ['--help']) | 580 self.cli.run(sys.argv + ['--help']) |
554 self.fail('Expected SystemExit') | 581 self.fail('Expected SystemExit') |
555 except SystemExit, e: | 582 except SystemExit, e: |