← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/recife-test_translatablemessage-cleanup into lp:~launchpad/launchpad/recife

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/recife-test_translatablemessage-cleanup into lp:~launchpad/launchpad/recife.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


= Pre-cleanup of test_translatablemessage =

This is a preparation for unrelated changes to the same file in work on our Recife feature branch.  I'm cleaning up several things in that test:

1. Base class used by all test cases is not a test case, yet inherits from TestCaseWithFactory.  Make only the real test cases inherit from that.

2. Useless "test suite" boilerplate at the end of the test.  Not needed nowadays.  Also takes an import with it.

3. Bad indent.  Our coding guidelines forbid method calls in the style of

    foo.goDoSomething(bar, splat,
                      cough, ghee)

To test, run just this one test:
{{{
./bin/test -vvc lp.translations.tests.test_translatablemessage
}}}

No Q/A required, no lint found.


Jeroen
-- 
https://code.launchpad.net/~jtv/launchpad/recife-test_translatablemessage-cleanup/+merge/40930
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/recife-test_translatablemessage-cleanup into lp:~launchpad/launchpad/recife.
=== modified file 'lib/lp/translations/tests/test_translatablemessage.py'
--- lib/lp/translations/tests/test_translatablemessage.py	2010-11-04 09:32:28 +0000
+++ lib/lp/translations/tests/test_translatablemessage.py	2010-11-16 06:25:00 +0000
@@ -9,7 +9,6 @@
     datetime,
     timedelta,
     )
-from unittest import TestLoader
 
 import pytz
 import transaction
@@ -22,7 +21,7 @@
 from lp.translations.model.translatablemessage import TranslatableMessage
 
 
-class TestTranslatableMessageBase(TestCaseWithFactory):
+class TestTranslatableMessageBase:
     """Common setup for `TranslatableMessage`."""
 
     layer = ZopelessDatabaseLayer
@@ -64,7 +63,8 @@
                 date_updated=date_updated)
 
 
-class TestTranslatableMessage(TestTranslatableMessageBase):
+class TestTranslatableMessage(TestTranslatableMessageBase,
+                              TestCaseWithFactory):
     """Test of `TranslatableMessage` properties and methods."""
 
     def test_sequence(self):
@@ -137,7 +137,8 @@
         self.assertEqual(translation, shared)
 
 
-class TestTranslatableMessageExternal(TestTranslatableMessageBase):
+class TestTranslatableMessageExternal(TestTranslatableMessageBase,
+                                      TestCaseWithFactory):
     """Test of `TranslatableMessage` methods for external translations."""
 
     def setUp(self):
@@ -177,7 +178,8 @@
         self.assertContentEqual([self.external_suggestion], externals)
 
 
-class TestTranslatableMessageSuggestions(TestTranslatableMessageBase):
+class TestTranslatableMessageSuggestions(TestTranslatableMessageBase,
+                                         TestCaseWithFactory):
     """Test of `TranslatableMessage` methods for getting suggestions."""
 
     def gen_now(self):
@@ -198,8 +200,8 @@
     def test_getAllSuggestions(self):
         # There are three different methods to return.
         suggestions = self.message.getAllSuggestions()
-        self.assertContentEqual([self.suggestion1, self.suggestion2],
-                                suggestions)
+        self.assertContentEqual(
+            [self.suggestion1, self.suggestion2], suggestions)
 
     def test_getDismissedSuggestions(self):
         # There are three different methods to return.
@@ -215,11 +217,6 @@
         # Add a suggestion that is newer than the current translation and
         # dismiss it. Also show that getSuggestions only returns translations
         # that are newer than the current one unless only_new is set to False.
-
         self.message.dismissAllSuggestions(self.potemplate.owner, self.now())
         suggestions = self.message.getUnreviewedSuggestions()
         self.assertContentEqual([], suggestions)
-
-
-def test_suite():
-    return TestLoader().loadTestsFromName(__name__)