summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <ramiro@rmorales.net>2013-10-01 20:23:36 -0300
committerRamiro Morales <ramiro@rmorales.net>2013-10-01 20:37:43 -0300
commit4b715fc05a75c375d5afe1860ce748ae2a2e290b (patch)
treec86574e7000aa0238354143c8e9b4f687c9728c3 /tests
parent1d0fc61b1cadee584a27dbbe3ef3e21fd3202c85 (diff)
Fixed #21209 -- .po file path comments on Windows.
Literals from source files with Django template language syntax don't have a '.py' suffix anymore. Also, the '.\' prefix is preserved to respect GNU gettext behavior on that platform. Refs #16903.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/commands/extraction.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/i18n/commands/extraction.py b/tests/i18n/commands/extraction.py
index dd1dce2ed0..4139abdd37 100644
--- a/tests/i18n/commands/extraction.py
+++ b/tests/i18n/commands/extraction.py
@@ -377,23 +377,39 @@ class NoWrapExtractorTests(ExtractorTests):
self.assertMsgId('""\n"This literal should also be included wrapped or not wrapped depending on the "\n"use of the --no-wrap option."', po_contents, use_quotes=False)
-class NoLocationExtractorTests(ExtractorTests):
+class LocationCommentsTests(ExtractorTests):
def test_no_location_enabled(self):
+ """Behavior is correct if --no-location switch is specified. See #16903."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=LOCALE, verbosity=0, no_location=True)
self.assertTrue(os.path.exists(self.PO_FILE))
with open(self.PO_FILE, 'r') as fp:
po_contents = force_text(fp.read())
- self.assertFalse('#: templates/test.html:55' in po_contents)
+ needle = os.sep.join(['#: templates', 'test.html:55'])
+ self.assertFalse(needle in po_contents, '"%s" shouldn\'t be in final .po file.' % needle)
def test_no_location_disabled(self):
+ """Behavior is correct if --no-location switch isn't specified."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=LOCALE, verbosity=0, no_location=False)
self.assertTrue(os.path.exists(self.PO_FILE))
with open(self.PO_FILE, 'r') as fp:
+ # Standard comment with source file relative path should be present -- #16903
po_contents = force_text(fp.read())
- self.assertTrue('#: templates/test.html:55' in po_contents)
+ if os.name == 'nt':
+ # #: .\path\to\file.html:123
+ cwd_prefix = '%s%s' % (os.curdir, os.sep)
+ else:
+ # #: path/to/file.html:123
+ cwd_prefix = ''
+ needle = os.sep.join(['#: %stemplates' % cwd_prefix, 'test.html:55'])
+ self.assertTrue(needle in po_contents, '"%s" not found in final .po file.' % needle)
+
+ # #21208 -- Leaky paths in comments on Windows e.g. #: path\to\file.html.py:123
+ bad_suffix = '.py'
+ bad_string = 'templates%stest.html%s' % (os.sep, bad_suffix) #
+ self.assertFalse(bad_string in po_contents, '"%s" shouldn\'t be in final .po file.' % bad_string)
class KeepPotFileExtractorTests(ExtractorTests):