Merge lp:~frankban/launchpad/bug-1012799 into lp:launchpad

Proposed by Francesco Banconi on 2012-06-14
Status: Merged
Approved by: Francesco Banconi on 2012-06-14
Approved revision: no longer in the source branch.
Merged at revision: 15419
Proposed branch: lp:~frankban/launchpad/bug-1012799
Merge into: lp:launchpad
Diff against target: 27 lines (+5/-2)
1 file modified
lib/lp/services/features/__init__.py (+5/-2)
To merge this branch: bzr merge lp:~frankban/launchpad/bug-1012799
Reviewer Review Type Date Requested Status
Francesco Banconi (community) Approve on 2012-06-14
Review via email: mp+110270@code.launchpad.net

Commit Message

Fixed uninstall_feature_controller: check features exists as an attribute of local thread before deleting it.

Description of the Change

= 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

To post a comment you must log in.
Francesco Banconi (frankban) wrote :

Approved by Graham.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/features/__init__.py'
2--- lib/lp/services/features/__init__.py 2012-06-08 08:54:37 +0000
3+++ lib/lp/services/features/__init__.py 2012-06-14 09:11:29 +0000
4@@ -181,6 +181,8 @@
5
6 import threading
7
8+from lazr.restful.utils import safe_hasattr
9+
10
11 __all__ = [
12 'currentScope',
13@@ -206,11 +208,12 @@
14
15
16 def uninstall_feature_controller():
17- """Remove the current feature controller from this thread.
18+ """Remove, if it exists, the current feature controller from this thread.
19
20 This function is used to create a pristine environment in tests.
21 """
22- del per_thread.features
23+ if safe_hasattr(per_thread, 'features'):
24+ del per_thread.features
25
26
27 def get_relevant_feature_controller():