Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70719

Re: where to put global testing value

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'importing': 0.05; 'url:bitbucket': 0.05; 'modify': 0.07; 'variables': 0.07; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'testing,': 0.09; 'changes': 0.15; 'appengine': 0.16; 'globals': 0.16; 'itself,': 0.16; 'merely': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:where': 0.16; 'url:py': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'module': 0.19; 'url:default': 0.19; 'import': 0.22; 'hack': 0.22; 'putting': 0.22; 'header:User-Agent:1': 0.23; 'proxy': 0.24; 'environment': 0.24; 'sort': 0.25; 'possibly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'skip:g 30': 0.30; "i'm": 0.30; 'supposed': 0.32; 'guess': 0.33; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'url:org': 0.36; 'level': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'kind': 0.63; 'more': 0.64
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: where to put global testing value
Date Tue, 29 Apr 2014 12:32:35 -0400
References <535FD086.7000003@chamonix.reportlab.co.uk>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 18.189.27.191
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
In-Reply-To <535FD086.7000003@chamonix.reportlab.co.uk>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9576.1398789168.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398789168 news.xs4all.nl 2964 [2001:888:2000:d::a6]:54815
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70719

Show key headers only | View raw


On 4/29/14 12:17 PM, Robin Becker wrote:
> A user complains that under AppEngine I'm not allowed to import __main__.
>
> I can fix this issue merely by putting a try block around the offending
> import which is only used like this
>
>
> import __main__
> testing = getattr(__main__,'_rl_testing',False)
> del __main__
>
> this is only used as a hack way, during testing, to modify the behaviour
> of the importing module (a proxy for a C extension). During testing we
> keep both the C version and the supposed replacement of various
> functions so they can be tested against each other
>
> https://bitbucket.org/rptlab/reportlab/src/default/src/reportlab/lib/rl_accel.py
>
>
> Is there a more reasonable way to allow changes to module level globals
> before the import takes place? I guess since this module is supposed
> only to be imported by reportlab we can put this sort of thing onto the
> reportlab module itself, but that could possibly lead to import loops.
>
> Any ideas?

In coverage.py, I used environment variables to control that kind of 
behavior.

-- 
Ned Batchelder, http://nedbatchelder.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: where to put global testing value Ned Batchelder <ned@nedbatchelder.com> - 2014-04-29 12:32 -0400

csiph-web