← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/bug-954319 into lp:launchpad

 

Benji York has proposed merging lp:~benji/launchpad/bug-954319 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #954319 in Launchpad itself: "Test isolation: some test is switching to readonly mode and not switching back on teardown"
  https://bugs.launchpad.net/launchpad/+bug/954319

For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-954319/+merge/97491

This branch fixes a test isolation bug that causes read-only mode to get stuck on when the test are run in a semi-random order (as when running them in parallel).

The problem is that a test request was leaking out of these tests so the fix was to end the current interaction in the tearDown.

Both the subset of the tests that exhibited the problem (see linked bug) and a much larger test run (comprising half of all the tests) nolonger provke the bug.

I also fixed a bit trailing whitespace lint in lib/lp/services/database/tests/test_readonly.py.
-- 
https://code.launchpad.net/~benji/launchpad/bug-954319/+merge/97491
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-954319 into lp:launchpad.
=== modified file 'lib/lp/services/database/tests/test_readonly.py'
--- lib/lp/services/database/tests/test_readonly.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/database/tests/test_readonly.py	2012-03-14 19:03:29 +0000
@@ -4,6 +4,7 @@
 __metaclass__ = type
 
 from lazr.restful.utils import get_current_browser_request
+from zope.security.management import endInteraction
 
 from lp.services.database.readonly import (
     is_read_only,
@@ -48,6 +49,7 @@
         # Safety net just in case a test leaves the read-only.txt file behind.
         if read_only_file_exists():
             remove_read_only_file()
+        endInteraction()
         super(Test_is_read_only, self).tearDown()
 
     def test_is_read_only(self):
@@ -75,7 +77,7 @@
         self.assertFalse(
             request.annotations.get(READ_ONLY_MODE_ANNOTATIONS_KEY))
 
-    def test_cached_value_takes_precedence(self): 
+    def test_cached_value_takes_precedence(self):
         # Once the request has the read-only flag, we don't check for the
         # presence of the read-only.txt file anymore, so it could be removed
         # and the request would still be in read-only mode.