mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #23395 -- Limited line lengths to 119 characters.
This commit is contained in:
committed by
Tim Graham
parent
84b0a8d2aa
commit
b1e33ceced
@@ -180,7 +180,11 @@ class BasicExtractorTests(ExtractorTests):
|
||||
|
||||
# Comments in templates
|
||||
self.assertIn('#. Translators: This comment should be extracted', po_contents)
|
||||
self.assertIn("#. Translators: Django comment block for translators\n#. string's meaning unveiled", po_contents)
|
||||
self.assertIn(
|
||||
"#. Translators: Django comment block for translators\n#. "
|
||||
"string's meaning unveiled",
|
||||
po_contents
|
||||
)
|
||||
self.assertIn('#. Translators: One-line translator comment #1', po_contents)
|
||||
self.assertIn('#. Translators: Two-line translator comment #1\n#. continued here.', po_contents)
|
||||
self.assertIn('#. Translators: One-line translator comment #2', po_contents)
|
||||
@@ -189,8 +193,16 @@ class BasicExtractorTests(ExtractorTests):
|
||||
self.assertIn('#. Translators: Two-line translator comment #3\n#. continued here.', po_contents)
|
||||
self.assertIn('#. Translators: One-line translator comment #4', po_contents)
|
||||
self.assertIn('#. Translators: Two-line translator comment #4\n#. continued here.', po_contents)
|
||||
self.assertIn('#. Translators: One-line translator comment #5 -- with non ASCII characters: áéíóúö', po_contents)
|
||||
self.assertIn('#. Translators: Two-line translator comment #5 -- with non ASCII characters: áéíóúö\n#. continued here.', po_contents)
|
||||
self.assertIn(
|
||||
'#. Translators: One-line translator comment #5 -- with '
|
||||
'non ASCII characters: áéíóúö',
|
||||
po_contents
|
||||
)
|
||||
self.assertIn(
|
||||
'#. Translators: Two-line translator comment #5 -- with '
|
||||
'non ASCII characters: áéíóúö\n#. continued here.',
|
||||
po_contents
|
||||
)
|
||||
|
||||
def test_blocktrans_trimmed(self):
|
||||
os.chdir(self.test_dir)
|
||||
@@ -212,13 +224,12 @@ class BasicExtractorTests(ExtractorTests):
|
||||
|
||||
def test_extraction_error(self):
|
||||
os.chdir(self.test_dir)
|
||||
self.assertRaises(SyntaxError, management.call_command, 'makemessages', locale=[LOCALE], extensions=['tpl'], verbosity=0)
|
||||
with self.assertRaises(SyntaxError) as context_manager:
|
||||
management.call_command('makemessages', locale=[LOCALE], extensions=['tpl'], verbosity=0)
|
||||
six.assertRegex(
|
||||
self, str(context_manager.exception),
|
||||
r'Translation blocks must not include other block tags: blocktrans \(file templates[/\\]template_with_error\.tpl, line 3\)'
|
||||
msg = (
|
||||
'Translation blocks must not include other block tags: blocktrans '
|
||||
'(file %s, line 3)' % os.path.join('templates', 'template_with_error.tpl')
|
||||
)
|
||||
with self.assertRaisesMessage(SyntaxError, msg):
|
||||
management.call_command('makemessages', locale=[LOCALE], extensions=['tpl'], verbosity=0)
|
||||
# Check that the temporary file was cleaned up
|
||||
self.assertFalse(os.path.exists('./templates/template_with_error.tpl.py'))
|
||||
|
||||
@@ -303,15 +314,21 @@ class BasicExtractorTests(ExtractorTests):
|
||||
self.assertTrue(issubclass(w.category, TranslatorCommentWarning))
|
||||
six.assertRegex(
|
||||
self, str(ws[0].message),
|
||||
r"The translator-targeted comment 'Translators: ignored i18n comment #1' \(file templates[/\\]comments.thtml, line 4\) was ignored, because it wasn't the last item on the line\."
|
||||
r"The translator-targeted comment 'Translators: ignored i18n "
|
||||
r"comment #1' \(file templates[/\\]comments.thtml, line 4\) "
|
||||
r"was ignored, because it wasn't the last item on the line\."
|
||||
)
|
||||
six.assertRegex(
|
||||
self, str(ws[1].message),
|
||||
r"The translator-targeted comment 'Translators: ignored i18n comment #3' \(file templates[/\\]comments.thtml, line 6\) was ignored, because it wasn't the last item on the line\."
|
||||
r"The translator-targeted comment 'Translators: ignored i18n "
|
||||
r"comment #3' \(file templates[/\\]comments.thtml, line 6\) "
|
||||
r"was ignored, because it wasn't the last item on the line\."
|
||||
)
|
||||
six.assertRegex(
|
||||
self, str(ws[2].message),
|
||||
r"The translator-targeted comment 'Translators: ignored i18n comment #4' \(file templates[/\\]comments.thtml, line 8\) was ignored, because it wasn't the last item on the line\."
|
||||
r"The translator-targeted comment 'Translators: ignored i18n "
|
||||
r"comment #4' \(file templates[/\\]comments.thtml, line 8\) "
|
||||
"was ignored, because it wasn't the last item on the line\."
|
||||
)
|
||||
# Now test .po file contents
|
||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||
@@ -581,7 +598,11 @@ class NoWrapExtractorTests(ExtractorTests):
|
||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||
with open(self.PO_FILE, 'r') as fp:
|
||||
po_contents = force_text(fp.read())
|
||||
self.assertMsgId('This literal should also be included wrapped or not wrapped depending on the use of the --no-wrap option.', po_contents)
|
||||
self.assertMsgId(
|
||||
'This literal should also be included wrapped or not wrapped '
|
||||
'depending on the use of the --no-wrap option.',
|
||||
po_contents
|
||||
)
|
||||
|
||||
def test_no_wrap_disabled(self):
|
||||
os.chdir(self.test_dir)
|
||||
@@ -589,7 +610,12 @@ class NoWrapExtractorTests(ExtractorTests):
|
||||
self.assertTrue(os.path.exists(self.PO_FILE))
|
||||
with open(self.PO_FILE, 'r') as fp:
|
||||
po_contents = force_text(fp.read())
|
||||
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)
|
||||
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 LocationCommentsTests(ExtractorTests):
|
||||
|
||||
Reference in New Issue
Block a user