launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #16879
[Merge] lp:~cjwatson/launchpad/translations-pyflakes into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/translations-pyflakes into lp:launchpad.
Commit message:
Fix various pyflakes/lint errors in translations.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/translations-pyflakes/+merge/222654
Fix various pyflakes/lint errors in translations.
--
https://code.launchpad.net/~cjwatson/launchpad/translations-pyflakes/+merge/222654
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/translations-pyflakes into lp:launchpad.
=== modified file 'lib/lp/translations/browser/tests/test_persontranslationview.py'
--- lib/lp/translations/browser/tests/test_persontranslationview.py 2013-01-14 03:35:35 +0000
+++ lib/lp/translations/browser/tests/test_persontranslationview.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -225,7 +225,7 @@
# top_projects_and_packages will show at most 9 POFiles
# overall.
self._makeReviewer()
- pofiles_worked_on = self._makePOFiles(11, previously_worked_on=True)
+ self._makePOFiles(11, previously_worked_on=True)
targets = self.view.top_projects_and_packages_to_review
@@ -407,13 +407,13 @@
self.assertFalse("+edit" in browser.contents)
def test_links_unauthorized(self):
- group = self.factory.makeTranslationGroup()
+ self.factory.makeTranslationGroup()
browser = self.getViewBrowser(self.context, "+translations")
self.assertFalse("+editmylanguages" in browser.contents)
self.assertFalse("+edit" in browser.contents)
def test_links_authorized(self):
- group = self.factory.makeTranslationGroup()
+ self.factory.makeTranslationGroup()
browser = self.getViewBrowser(
self.context, "+translations", user=self.context)
self.assertTrue("+editmylanguages" in browser.contents)
=== modified file 'lib/lp/translations/browser/tests/test_poexportrequest_views.py'
--- lib/lp/translations/browser/tests/test_poexportrequest_views.py 2013-06-20 05:50:00 +0000
+++ lib/lp/translations/browser/tests/test_poexportrequest_views.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -75,7 +75,7 @@
def test_request_some_potemplate(self):
# Using 'some' allows to select only the template.
- pofile = self.factory.makePOFile(potemplate=self.potemplate)
+ self.factory.makePOFile(potemplate=self.potemplate)
self._createView({'what': 'some', 'potemplate': True, 'format': 'PO'})
self.assertContentEqual(
@@ -91,7 +91,7 @@
def test_request_some_various(self):
# Using 'some' allows to select various files.
- pofile1 = self.factory.makePOFile(potemplate=self.potemplate)
+ self.factory.makePOFile(potemplate=self.potemplate)
pofile2 = self.factory.makePOFile(potemplate=self.potemplate)
self._createView({
'what': 'some',
=== modified file 'lib/lp/translations/browser/tests/test_pofile_view.py'
--- lib/lp/translations/browser/tests/test_pofile_view.py 2012-02-15 21:14:05 +0000
+++ lib/lp/translations/browser/tests/test_pofile_view.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -304,7 +304,7 @@
with person_logged_in(product.owner):
product.translationpermission = TranslationPermission.CLOSED
# Add credits so that they show in the UI
- credits = self.factory.makePOTMsgSet(
+ self.factory.makePOTMsgSet(
potemplate=pofile.potemplate, singular='translator-credits')
browser = self.getViewBrowser(pofile)
self.assertNotIn('This is a dummy translation', browser.contents)
@@ -313,10 +313,8 @@
def test_anonymous_translation_credits(self):
"""Credits should be hidden for non-logged-in users."""
pofile = self.factory.makePOFile()
- # Restrict translations so that the translator cannot change it.
- product = pofile.potemplate.productseries.product
# Add credits so that they show in the UI
- credits = self.factory.makePOTMsgSet(
+ self.factory.makePOTMsgSet(
potemplate=pofile.potemplate, singular='translator-credits')
browser = self.getViewBrowser(pofile, no_login=True)
self.assertTextMatchesExpressionIgnoreWhitespace(
=== modified file 'lib/lp/translations/browser/tests/test_sharing_information.py'
--- lib/lp/translations/browser/tests/test_sharing_information.py 2013-01-03 00:27:37 +0000
+++ lib/lp/translations/browser/tests/test_sharing_information.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for the POTemplate recipe view classes and templates."""
@@ -6,7 +6,6 @@
__metaclass__ = type
from lp.app.enums import ServiceUsage
-from lp.services.features.testing import FeatureFixture
from lp.testing import (
BrowserTestCase,
celebrity_logged_in,
=== modified file 'lib/lp/translations/browser/tests/test_translationmessage_view.py'
--- lib/lp/translations/browser/tests/test_translationmessage_view.py 2014-02-19 04:01:46 +0000
+++ lib/lp/translations/browser/tests/test_translationmessage_view.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
from __future__ import with_statement
@@ -477,12 +477,12 @@
revert_unselected_translations(
new_translations, current_message, []))
+
class TestBadSubmission(TestCaseWithFactory):
layer = DatabaseFunctionalLayer
def getSubmission(self, good=True):
- original_translations = {0: self.getUniqueString()}
pofile = self.factory.makePOFile()
current = self.factory.makeCurrentTranslationMessage(pofile=pofile)
message = self.factory.makeSuggestion(pofile=pofile)
=== modified file 'lib/lp/translations/interfaces/webservice.py'
--- lib/lp/translations/interfaces/webservice.py 2013-01-07 02:40:55 +0000
+++ lib/lp/translations/interfaces/webservice.py 2014-06-10 13:44:53 +0000
@@ -14,6 +14,7 @@
'IPOFile',
'IPOTemplate',
'ITranslationGroup',
+ 'ITranslationGroupSet',
'ITranslationImportQueue',
'ITranslationImportQueueEntry',
]
=== modified file 'lib/lp/translations/tests/test_pofilestatsjob.py'
--- lib/lp/translations/tests/test_pofilestatsjob.py 2013-07-04 08:32:03 +0000
+++ lib/lp/translations/tests/test_pofilestatsjob.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for merging translations."""
@@ -9,7 +9,6 @@
import transaction
from lp.app.enums import ServiceUsage
-from lp.services.config import config
from lp.services.features.testing import FeatureFixture
from lp.services.job.interfaces.job import (
IJobSource,
=== modified file 'lib/lp/translations/tests/test_translationmessage.py'
--- lib/lp/translations/tests/test_translationmessage.py 2012-12-26 01:32:19 +0000
+++ lib/lp/translations/tests/test_translationmessage.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Unit tests for `TranslationMessage`."""
@@ -77,6 +77,62 @@
self.assertEqual(reviewer, message.reviewer)
self.assertEqual(tomorrow, message.date_reviewed)
+ def test_getOnePOFile(self):
+ language = self.factory.makeLanguage('sr@test')
+ pofile = self.factory.makePOFile(language.code)
+ tm = self.factory.makeCurrentTranslationMessage(pofile=pofile)
+ self.assertEquals(pofile, tm.getOnePOFile())
+
+ def test_getOnePOFile_shared(self):
+ language = self.factory.makeLanguage('sr@test')
+ pofile1 = self.factory.makePOFile(language.code)
+ pofile2 = self.factory.makePOFile(language.code)
+ tm = self.factory.makeCurrentTranslationMessage(pofile=pofile1)
+ # Share this POTMsgSet with the other POTemplate (and POFile).
+ tm.potmsgset.setSequence(pofile2.potemplate, 1)
+ self.assertTrue(tm.getOnePOFile() in [pofile1, pofile2])
+
+ def test_getOnePOFile_no_pofile(self):
+ # When POTMsgSet is obsolete (sequence=0), no matching POFile
+ # is returned.
+ language = self.factory.makeLanguage('sr@test')
+ pofile = self.factory.makePOFile(language.code)
+ tm = self.factory.makeCurrentTranslationMessage(pofile=pofile)
+ tm.potmsgset.setSequence(pofile.potemplate, 0)
+ self.assertEquals(None, tm.getOnePOFile())
+
+ def test_clone(self):
+ """Cloning a translation should produce a near-identical copy."""
+ translations = [self.factory.getUniqueString() for x in range(6)]
+ tm = self.factory.makeCurrentTranslationMessage(
+ date_created=self.factory.getUniqueDate(),
+ translations=translations, current_other=True)
+ tm.comment = self.factory.getUniqueString()
+ tm.was_obsolete_in_last_import = True
+ potmsgset = self.factory.makePOTMsgSet()
+ clone = tm.clone(potmsgset)
+ self.assertNotEqual(tm.id, clone.id)
+ self.assertIs(None, clone.potemplate)
+ self.assertEqual(potmsgset, clone.potmsgset)
+ self.assertEqual(tm.submitter, clone.submitter)
+ self.assertEqual(tm.language, clone.language)
+ self.assertEqual(tm.origin, clone.origin)
+ self.assertEqual(tm.date_created, clone.date_created)
+ self.assertEqual(tm.reviewer, clone.reviewer)
+ self.assertEqual(tm.date_reviewed, clone.date_reviewed)
+ self.assertEqual(tm.msgstr0, clone.msgstr0)
+ self.assertEqual(tm.msgstr1, clone.msgstr1)
+ self.assertEqual(tm.msgstr2, clone.msgstr2)
+ self.assertEqual(tm.msgstr3, clone.msgstr3)
+ self.assertEqual(tm.msgstr4, clone.msgstr4)
+ self.assertEqual(tm.msgstr5, clone.msgstr5)
+ self.assertEqual(tm.comment, clone.comment)
+ self.assertEqual(tm.validation_status, clone.validation_status)
+ self.assertEqual(tm.is_current_ubuntu, clone.is_current_ubuntu)
+ self.assertEqual(tm.is_current_upstream, clone.is_current_upstream)
+ self.assertEqual(
+ tm.was_obsolete_in_last_import, clone.was_obsolete_in_last_import)
+
class TestApprove(TestCaseWithFactory):
"""Tests for `TranslationMessage.approve`."""
@@ -277,7 +333,7 @@
def test_approve_clones_message_from_other_side_to_diverge(self):
package = self.factory.makeSourcePackage()
- template=self.factory.makePOTemplate(
+ template = self.factory.makePOTemplate(
distroseries=package.distroseries,
sourcepackagename=package.sourcepackagename)
potmsgset = self.factory.makePOTMsgSet(potemplate=template)
@@ -759,68 +815,6 @@
self.assertEqual(suggestion.date_reviewed, pofile.date_changed)
-class TestTranslationMessage(TestCaseWithFactory):
- """Basic unit tests for TranslationMessage class.
- """
- layer = ZopelessDatabaseLayer
-
- def test_getOnePOFile(self):
- language = self.factory.makeLanguage('sr@test')
- pofile = self.factory.makePOFile(language.code)
- tm = self.factory.makeCurrentTranslationMessage(pofile=pofile)
- self.assertEquals(pofile, tm.getOnePOFile())
-
- def test_getOnePOFile_shared(self):
- language = self.factory.makeLanguage('sr@test')
- pofile1 = self.factory.makePOFile(language.code)
- pofile2 = self.factory.makePOFile(language.code)
- tm = self.factory.makeCurrentTranslationMessage(pofile=pofile1)
- # Share this POTMsgSet with the other POTemplate (and POFile).
- tm.potmsgset.setSequence(pofile2.potemplate, 1)
- self.assertTrue(tm.getOnePOFile() in [pofile1, pofile2])
-
- def test_getOnePOFile_no_pofile(self):
- # When POTMsgSet is obsolete (sequence=0), no matching POFile
- # is returned.
- language = self.factory.makeLanguage('sr@test')
- pofile = self.factory.makePOFile(language.code)
- tm = self.factory.makeCurrentTranslationMessage(pofile=pofile)
- tm.potmsgset.setSequence(pofile.potemplate, 0)
- self.assertEquals(None, tm.getOnePOFile())
-
- def test_clone(self):
- """Cloning a translation should produce a near-identical copy."""
- translations = [self.factory.getUniqueString() for x in range(6)]
- tm = self.factory.makeCurrentTranslationMessage(
- date_created=self.factory.getUniqueDate(),
- translations=translations, current_other=True)
- tm.comment = self.factory.getUniqueString()
- tm.was_obsolete_in_last_import = True
- potmsgset = self.factory.makePOTMsgSet()
- clone = tm.clone(potmsgset)
- self.assertNotEqual(tm.id, clone.id)
- self.assertIs(None, clone.potemplate)
- self.assertEqual(potmsgset, clone.potmsgset)
- self.assertEqual(tm.submitter, clone.submitter)
- self.assertEqual(tm.language, clone.language)
- self.assertEqual(tm.origin, clone.origin)
- self.assertEqual(tm.date_created, clone.date_created)
- self.assertEqual(tm.reviewer, clone.reviewer)
- self.assertEqual(tm.date_reviewed, clone.date_reviewed)
- self.assertEqual(tm.msgstr0, clone.msgstr0)
- self.assertEqual(tm.msgstr1, clone.msgstr1)
- self.assertEqual(tm.msgstr2, clone.msgstr2)
- self.assertEqual(tm.msgstr3, clone.msgstr3)
- self.assertEqual(tm.msgstr4, clone.msgstr4)
- self.assertEqual(tm.msgstr5, clone.msgstr5)
- self.assertEqual(tm.comment, clone.comment)
- self.assertEqual(tm.validation_status, clone.validation_status)
- self.assertEqual(tm.is_current_ubuntu, clone.is_current_ubuntu)
- self.assertEqual(tm.is_current_upstream, clone.is_current_upstream)
- self.assertEqual(
- tm.was_obsolete_in_last_import, clone.was_obsolete_in_last_import)
-
-
class TestTranslationMessageFindIdenticalMessage(TestCaseWithFactory):
"""Tests for `TranslationMessage.findIdenticalMessage`."""
@@ -995,7 +989,7 @@
def shareIfPossibleDeletes(translation):
translation.shareIfPossible()
result = Store.of(translation).find(
- TranslationMessage, TranslationMessage.id==translation.id)
+ TranslationMessage, TranslationMessage.id == translation.id)
return result.is_empty()
def test_share_success(self):
=== modified file 'lib/lp/translations/tests/test_translationpolicy.py'
--- lib/lp/translations/tests/test_translationpolicy.py 2012-01-01 02:58:52 +0000
+++ lib/lp/translations/tests/test_translationpolicy.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test `TranslationPolicyMixin`."""
@@ -169,7 +169,7 @@
def test_getEffectiveTranslationPermission_returns_maximum(self):
# When combining permissions, getEffectiveTranslationPermission
# returns the one with the highest numerical value.
- parent = self._makeParentPolicy()
+ self._makeParentPolicy()
for child_permission in TranslationPermission.items:
for parent_permission in TranslationPermission.items:
self._setPermissions(child_permission, parent_permission)
=== modified file 'lib/lp/translations/utilities/gettext_po_parser.py'
--- lib/lp/translations/utilities/gettext_po_parser.py 2013-01-07 03:21:35 +0000
+++ lib/lp/translations/utilities/gettext_po_parser.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# Originally based on code from msgfmt.py (available from python source
@@ -225,7 +225,7 @@
"""Attempt to parse `date_string`, or return None if invalid."""
try:
return zope_datetime.parseDatetimetz(date_string)
- except (ValueError, zope_datetime.DateTimeError) as exception:
+ except (ValueError, zope_datetime.DateTimeError):
return None
def _parseHeaderFields(self):
@@ -579,7 +579,7 @@
self._storeCurrentMessage()
else:
raise TranslationFormatSyntaxError(
- line_number = self._lineno,
+ line_number=self._lineno,
message='Got a truncated message!')
return self._translation_file
@@ -1042,4 +1042,4 @@
line_number=self._lineno,
message='Invalid content: %r' % original_line)
- self._parsed_content += line
+ self._parsed_content += line
=== modified file 'lib/lp/translations/utilities/tests/test_export_file_storage.py'
--- lib/lp/translations/utilities/tests/test_export_file_storage.py 2011-12-28 17:03:06 +0000
+++ lib/lp/translations/utilities/tests/test_export_file_storage.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for `ExportFileStorage`."""
@@ -19,7 +19,6 @@
def testEmpty(self):
"""Behaviour of empty storage."""
- mime = 'application/x-po'
storage = ExportFileStorage()
# Try not inserting any files, so the storage object remains empty.
self.assertTrue(storage._store.isEmpty())
=== modified file 'lib/lp/translations/utilities/translation_export.py'
--- lib/lp/translations/utilities/translation_export.py 2010-12-17 12:40:24 +0000
+++ lib/lp/translations/utilities/translation_export.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Components for exporting translation files."""
@@ -91,7 +91,7 @@
output_format = target_format
format_exporter = self.getExporterProducingTargetFileFormat(
output_format)
- file_content = format_exporter.exportTranslationFile(
+ format_exporter.exportTranslationFile(
translation_file, storage, ignore_obsolete=ignore_obsolete,
force_utf8=force_utf8)
=== modified file 'lib/lp/translations/utilities/xpi_manifest.py'
--- lib/lp/translations/utilities/xpi_manifest.py 2010-08-20 20:31:18 +0000
+++ lib/lp/translations/utilities/xpi_manifest.py 2014-06-10 13:44:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -159,7 +159,6 @@
deletions.append(index)
paths.add(entry.path)
- last_entry = entry
for index in reversed(deletions):
del locales[index]
@@ -236,4 +235,3 @@
entry.path + chrome_path[len(entry.chrome):])
return None
-
Follow ups