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


Groups > comp.lang.python > #70719 > unrolled thread

Re: where to put global testing value

Started byNed Batchelder <ned@nedbatchelder.com>
First post2014-04-29 12:32 -0400
Last post2014-04-29 12:32 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#70719 — Re: where to put global testing value

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-04-29 12:32 -0400
SubjectRe: where to put global testing value
Message-ID<mailman.9576.1398789168.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web