Mercurial > babel > old > mirror
changeset 136:9e3d2b227ec3
More fixes for Windows compatibility:
* normalize path segment separator to "/"
* use `dates.format_date` also to set the expected date-strings in the frontend tests.
author | cmlenz |
---|---|
date | Tue, 19 Jun 2007 12:13:46 +0000 |
parents | 5969b610d0ec |
children | ade36d5897f4 |
files | babel/messages/pofile.py babel/messages/tests/frontend.py babel/util.py |
diffstat | 3 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -19,6 +19,7 @@ """ from datetime import date, datetime +import os import re try: set @@ -353,7 +354,8 @@ _write('#. %s\n' % line.strip()) if not no_location: - locs = u' '.join([u'%s:%d' % item for item in message.locations]) + locs = u' '.join([u'%s:%d' % (filename.replace(os.sep, '/'), lineno) + for filename, lineno in message.locations]) if width and width > 0: locs = wrap(locs, width, break_long_words=False) for line in locs:
--- a/babel/messages/tests/frontend.py +++ b/babel/messages/tests/frontend.py @@ -11,6 +11,7 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. +from datetime import datetime from distutils.dist import Distribution from distutils.errors import DistutilsOptionError, DistutilsSetupError from distutils.log import _global_log @@ -23,7 +24,9 @@ import unittest from babel import __version__ as VERSION +from babel.dates import format_datetime from babel.messages import frontend +from babel.util import LOCALTZ class ExtractMessagesTestCase(unittest.TestCase): @@ -116,7 +119,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extraction_with_mapping_file(self): self.cmd.copyright_holder = 'FooBar, Inc.' @@ -166,7 +171,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extraction_with_mapping_dict(self): self.dist.message_extractors = { @@ -221,7 +228,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) class NewCatalogTestCase(unittest.TestCase): @@ -304,7 +313,8 @@ msgstr[1] "" """ % {'version': VERSION, - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, open(po_file, 'U').read()) @@ -407,7 +417,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_extract_with_mapping_file(self): pot_file = os.path.join(self.datadir, 'project', 'i18n', 'temp.pot') @@ -456,7 +468,9 @@ """ % {'version': VERSION, 'year': time.strftime('%Y'), - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, open(pot_file, 'U').read()) + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, + open(pot_file, 'U').read()) def test_init_with_output_dir(self): po_file = os.path.join(self.datadir, 'project', 'i18n', 'en_US', @@ -505,7 +519,8 @@ msgstr[1] "" """ % {'version': VERSION, - 'date': time.strftime('%Y-%m-%d %H:%M%z')}, + 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', + tzinfo=LOCALTZ, locale='en')}, open(po_file, 'U').read())