summaryrefslogtreecommitdiff
path: root/tests/i18n/test_extraction.py
diff options
context:
space:
mode:
authorDražen Odobašić <dodobas@candela-it.com>2015-09-11 19:33:12 -0400
committerTim Graham <timograham@gmail.com>2015-09-12 11:40:50 -0400
commitb1e33ceceda1e75ff68c7deed8f6659683a195d3 (patch)
treee4e446f69194f2dc3c9c7ee3ecf48290ea8d4d31 /tests/i18n/test_extraction.py
parent84b0a8d2aad042fb573df5055b6153770d0929ac (diff)
downloaddjango-b1e33ceceda1e75ff68c7deed8f6659683a195d3.tar.gz
Fixed #23395 -- Limited line lengths to 119 characters.
Diffstat (limited to 'tests/i18n/test_extraction.py')
-rw-r--r--tests/i18n/test_extraction.py54
1 files changed, 40 insertions, 14 deletions
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index b9c4b4fc3e..e26ec29e43 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -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):