Merge lp:~jml/launchpad/shout-more-effectively into lp:launchpad

Proposed by Jonathan Lange
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11283
Proposed branch: lp:~jml/launchpad/shout-more-effectively
Merge into: lp:launchpad
Diff against target: 41 lines (+6/-10)
1 file modified
lib/lp/testing/factory.py (+6/-10)
To merge this branch: bzr merge lp:~jml/launchpad/shout-more-effectively
Reviewer Review Type Date Requested Status
Curtis Hovey (community) Approve
Review via email: mp+31664@code.launchpad.net

Commit message

remove_security_proxy_and_shout_at_engineer now gives clearer directions

Description of the change

This branch changes the warning generated by remove_security_proxy_and_shout_at_engineer to more clearly indicate what you should do.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/testing/factory.py'
2--- lib/lp/testing/factory.py 2010-08-01 04:34:26 +0000
3+++ lib/lp/testing/factory.py 2010-08-03 17:32:02 +0000
4@@ -31,7 +31,6 @@
5 import os.path
6 from random import randint
7 from StringIO import StringIO
8-import sys
9 from textwrap import dedent
10 from threading import local
11 from types import InstanceType
12@@ -2797,17 +2796,14 @@
13 "unproxied object." % (method_name,))
14
15
16-class UnreasonableRemoveSecurityProxyWarning(UserWarning):
17- """Raised when there is an unreasonable call to removeSecurityProxy."""
18-
19- # XXX: JonathanLange 2010-07-25: I have no idea what "unreasonable" means
20- # in this context.
21+class ShouldThisBeUsingRemoveSecurityProxy(UserWarning):
22+ """Raised when there is a potentially bad call to removeSecurityProxy."""
23
24 def __init__(self, obj):
25 message = (
26- "Called removeSecurityProxy(%r) without a check if this is "
27- "reasonable." % obj)
28- super(UnreasonableRemoveSecurityProxyWarning, self).__init__(message)
29+ "removeSecurityProxy(%r) called. Is this correct? "
30+ "Either call it directly or fix the test." % obj)
31+ super(ShouldThisBeUsingRemoveSecurityProxy, self).__init__(message)
32
33
34 class LaunchpadObjectFactory:
35@@ -2850,5 +2846,5 @@
36 This function should only be used in legacy tests which fail because
37 they expect unproxied objects.
38 """
39- warnings.warn(UnreasonableRemoveSecurityProxyWarning(obj), stacklevel=2)
40+ warnings.warn(ShouldThisBeUsingRemoveSecurityProxy(obj), stacklevel=2)
41 return removeSecurityProxy(obj)