~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/factory.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-08-05 21:25:12 UTC
  • mfrom: (11291.2.2 no-proxy-warnings)
  • Revision ID: launchpad@pqm.canonical.com-20100805212512-9y0sni32qx3e3vzk
[r=thumper][ui=none] Disable proxy warnings except when explicitly
        enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from email.mime.multipart import MIMEMultipart
29
29
from itertools import count
30
30
from operator import isSequenceType
 
31
import os
31
32
import os.path
32
33
from random import randint
33
34
from StringIO import StringIO
2866
2867
 
2867
2868
    def __getattr__(self, name):
2868
2869
        attr = getattr(self._factory, name)
2869
 
        if callable(attr):
 
2870
        if os.environ.get('LP_PROXY_WARNINGS') == '1' and callable(attr):
2870
2871
 
2871
2872
            def guarded_method(*args, **kw):
2872
2873
                result = attr(*args, **kw)
2889
2890
    This function should only be used in legacy tests which fail because
2890
2891
    they expect unproxied objects.
2891
2892
    """
2892
 
    warnings.warn(ShouldThisBeUsingRemoveSecurityProxy(obj), stacklevel=2)
 
2893
    if os.environ.get('LP_PROXY_WARNINGS') == '1':
 
2894
        warnings.warn(ShouldThisBeUsingRemoveSecurityProxy(obj), stacklevel=2)
2893
2895
    return removeSecurityProxy(obj)