Merge lp:~canonical-isd-hackers/u1-test-utils/patch_settings-fix into lp:u1-test-utils

Proposed by Michael Foord
Status: Merged
Approved by: Michael Nelson
Approved revision: 2
Merged at revision: 9
Proposed branch: lp:~canonical-isd-hackers/u1-test-utils/patch_settings-fix
Merge into: lp:u1-test-utils
Diff against target: 14 lines (+4/-2)
1 file modified
canonical/isd/tests/django.py (+4/-2)
To merge this branch: bzr merge lp:~canonical-isd-hackers/u1-test-utils/patch_settings-fix
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+80205@code.launchpad.net

Commit message

Undo patch_settings even when there is an exception.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks mfoord - that would have been a pain to catch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'canonical/isd/tests/django.py'
2--- canonical/isd/tests/django.py 2011-02-08 14:02:58 +0000
3+++ canonical/isd/tests/django.py 2011-10-24 12:49:14 +0000
4@@ -33,8 +33,10 @@
5 @contextmanager
6 def patch_settings(**kwargs):
7 old_settings = switch_settings(**kwargs)
8- yield
9- switch_settings(**old_settings)
10+ try:
11+ yield
12+ finally:
13+ switch_settings(**old_settings)
14 # end snippet
15
16

Subscribers

People subscribed via source and target branches

to all changes: