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

Proposed by Jeroen T. Vermeulen on 2010-11-16
Status: Merged
Approved by: Данило Шеган on 2010-11-16
Approved revision: no longer in the source branch.
Merged at revision: 9193
Proposed branch: lp:~jtv/launchpad/recife-test_translatablemessage-cleanup
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 73 lines (+9/-12)
1 file modified
lib/lp/translations/tests/test_translatablemessage.py (+9/-12)
To merge this branch: bzr merge lp:~jtv/launchpad/recife-test_translatablemessage-cleanup
Reviewer Review Type Date Requested Status
Данило Шеган (community) code 2010-11-16 Approve on 2010-11-16
Review via email: mp+40930@code.launchpad.net

Commit Message

test_translatablemessage pre-cleanup

Description of the Change

= 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

To post a comment you must log in.
Данило Шеган (danilo) wrote :

I find rule 3 very weird. One of the suggested styles for function *definitions* is that one, and you are even using that style for class definition where you inherit multiple classes. That smells of inconsistency in our style guide and should probably be fixed. We recently discussed (in the reviewers meeting) changing function definition style to not allow this style either, but I think the consensus was that we don't want to disallow it. Perhaps we should raise it in the reviewers meeting again to change *function call* style instead.

All good otherwise, thanks for the clean-up.

review: Approve (code)
Данило Шеган (danilo) wrote :

I mean, all is good (not "otherwise"), since the style you are using is definitely acceptable.

Jeroen T. Vermeulen (jtv) wrote :

Yes, it's weird. I never liked this style for definitions either. I used to indent like that for my first decade or so of C/C++ programming, but found that I like the fixed-indent style better.

I looked for possible justifications for having definitions and calls different, and found only these:

1. For a definition, indenting the continuation with a single tab brings you to the same level as the actual contents of the definition.

There's other ways of dealing with that though; a syntax-coloured docstring will provide a clear distinction for instance.

2. Re-indentation work when editing (grrr) is less likely to get out of hand in a definition than in calls.

That's only an argument of risk limitation though; it doesn't say that one is more or less likely to be more work than the other in the average case.

I wouldn't bother too much with changing the review rules here though, as per my rule of thumb that it's probably a waste of time to impose new rules unless we're also going back to fix the bulk of existing practice. What's already in the file is a much stronger and earlier influence than review rules.

Jeroen

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/tests/test_translatablemessage.py'
2--- lib/lp/translations/tests/test_translatablemessage.py 2010-11-04 09:32:28 +0000
3+++ lib/lp/translations/tests/test_translatablemessage.py 2010-11-16 06:27:02 +0000
4@@ -9,7 +9,6 @@
5 datetime,
6 timedelta,
7 )
8-from unittest import TestLoader
9
10 import pytz
11 import transaction
12@@ -22,7 +21,7 @@
13 from lp.translations.model.translatablemessage import TranslatableMessage
14
15
16-class TestTranslatableMessageBase(TestCaseWithFactory):
17+class TestTranslatableMessageBase:
18 """Common setup for `TranslatableMessage`."""
19
20 layer = ZopelessDatabaseLayer
21@@ -64,7 +63,8 @@
22 date_updated=date_updated)
23
24
25-class TestTranslatableMessage(TestTranslatableMessageBase):
26+class TestTranslatableMessage(TestTranslatableMessageBase,
27+ TestCaseWithFactory):
28 """Test of `TranslatableMessage` properties and methods."""
29
30 def test_sequence(self):
31@@ -137,7 +137,8 @@
32 self.assertEqual(translation, shared)
33
34
35-class TestTranslatableMessageExternal(TestTranslatableMessageBase):
36+class TestTranslatableMessageExternal(TestTranslatableMessageBase,
37+ TestCaseWithFactory):
38 """Test of `TranslatableMessage` methods for external translations."""
39
40 def setUp(self):
41@@ -177,7 +178,8 @@
42 self.assertContentEqual([self.external_suggestion], externals)
43
44
45-class TestTranslatableMessageSuggestions(TestTranslatableMessageBase):
46+class TestTranslatableMessageSuggestions(TestTranslatableMessageBase,
47+ TestCaseWithFactory):
48 """Test of `TranslatableMessage` methods for getting suggestions."""
49
50 def gen_now(self):
51@@ -198,8 +200,8 @@
52 def test_getAllSuggestions(self):
53 # There are three different methods to return.
54 suggestions = self.message.getAllSuggestions()
55- self.assertContentEqual([self.suggestion1, self.suggestion2],
56- suggestions)
57+ self.assertContentEqual(
58+ [self.suggestion1, self.suggestion2], suggestions)
59
60 def test_getDismissedSuggestions(self):
61 # There are three different methods to return.
62@@ -215,11 +217,6 @@
63 # Add a suggestion that is newer than the current translation and
64 # dismiss it. Also show that getSuggestions only returns translations
65 # that are newer than the current one unless only_new is set to False.
66-
67 self.message.dismissAllSuggestions(self.potemplate.owner, self.now())
68 suggestions = self.message.getUnreviewedSuggestions()
69 self.assertContentEqual([], suggestions)
70-
71-
72-def test_suite():
73- return TestLoader().loadTestsFromName(__name__)

Subscribers

People subscribed via source and target branches