From fdaa9b7ea3f189c3bcced4f22f4576f91d45839a Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 5 Jul 2013 12:50:53 +0200 Subject: [PATCH] Fixed tests that failed because of whitespace normalization --- babel/messages/catalog.py | 2 +- babel/messages/pofile.py | 2 +- babel/messages/tests/frontend.py | 5 ++--- babel/messages/tests/pofile.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/babel/messages/catalog.py b/babel/messages/catalog.py index abf96a1e..de991fa2 100644 --- a/babel/messages/catalog.py +++ b/babel/messages/catalog.py @@ -615,7 +615,7 @@ class Catalog(object): decoded_headers[name] = value return decoded_headers self.mime_headers = _parse_header(message.string).items() - self.header_comment = '\n'.join(['# %s' % comment for comment + self.header_comment = '\n'.join([('# %s' % c).rstrip() for c in message.user_comments]) self.fuzzy = message.fuzzy else: diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py index da904954..3afbaa39 100644 --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -18,7 +18,6 @@ format. `_ """ -from datetime import datetime import os import re @@ -88,6 +87,7 @@ def read_po(fileobj, locale=None, domain=None, ignore_obsolete=False): """Read messages from a ``gettext`` PO (portable object) file from the given file-like object and return a `Catalog`. + >>> from datetime import datetime >>> from StringIO import StringIO >>> buf = StringIO(''' ... #: main.py:1 diff --git a/babel/messages/tests/frontend.py b/babel/messages/tests/frontend.py index 2a9349a1..2d934e7e 100644 --- a/babel/messages/tests/frontend.py +++ b/babel/messages/tests/frontend.py @@ -86,7 +86,7 @@ class ExtractMessagesTestCase(unittest.TestCase): os.chdir(self.olddir) - def _i18n_dir(self): + def _i18n_dir(self): return os.path.join(self.datadir, 'project', 'i18n') def _pot_file(self): @@ -546,8 +546,7 @@ msgstr[0] "" po_file = self._po_file('en_US') assert os.path.isfile(po_file) - self.assertEqual( -r"""# English (United States) translations for TestProject. + self.assertEqual(r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. diff --git a/babel/messages/tests/pofile.py b/babel/messages/tests/pofile.py index 9d1d437f..f8a3d570 100644 --- a/babel/messages/tests/pofile.py +++ b/babel/messages/tests/pofile.py @@ -302,7 +302,7 @@ not be removed pofile.write_po(buf, catalog, no_location=True, omit_header=True, width=42) self.assertEqual(r'''msgid "" -"Here's some text where \n" +"Here's some text where\n" "white space and line breaks matter, and" " should\n" "\n" -- 2.47.2