Francesco Banconi has proposed merging lp:~frankban/launchpad/bug-1012799 into 
lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1012799 in Launchpad itself: 
"lp.testing.tests.test_testing.TestFeatureFlags.test_set_feature_flags_raises_if_not_available
 fails intermittently/rarely in parallel tests"
  https://bugs.launchpad.net/launchpad/+bug/1012799

For more details, see:
https://code.launchpad.net/~frankban/launchpad/bug-1012799/+merge/110270

= Summary =

TestFeatureFlags.test_set_feature_flags_raises_if_not_available fails when
run in isolation.

== Proposed fix ==

Check features exists as an attribute of local thread before deleting it.

== Tests ==

bin/test -cvvt 
lp.testing.tests.test_testing.TestFeatureFlags.test_set_feature_flags_raises_if_not_available

NO QA

-- 
https://code.launchpad.net/~frankban/launchpad/bug-1012799/+merge/110270
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~frankban/launchpad/bug-1012799 into lp:launchpad.
=== modified file 'lib/lp/services/features/__init__.py'
--- lib/lp/services/features/__init__.py	2012-06-08 08:54:37 +0000
+++ lib/lp/services/features/__init__.py	2012-06-14 09:11:29 +0000
@@ -181,6 +181,8 @@
 
 import threading
 
+from lazr.restful.utils import safe_hasattr
+
 
 __all__ = [
     'currentScope',
@@ -206,11 +208,12 @@
 
 
 def uninstall_feature_controller():
-    """Remove the current feature controller from this thread.
+    """Remove, if it exists, the current feature controller from this thread.
 
     This function is used to create a pristine environment in tests.
     """
-    del per_thread.features
+    if safe_hasattr(per_thread, 'features'):
+        del per_thread.features
 
 
 def get_relevant_feature_controller():

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to