doctest x idle problem?
tim.one at home.com
Sat Jul 28 11:02:09 CEST 2001
> Well, I was hoping to develop and test some modules within the idle
> environment. (I'm wondering how well IDLE serves as a primary
> Interactive Development Environment.)
It's mixed. That modules aren't automagically reloaded when running a
script is both a help and a curse, depending on what you're after in the
> I ran into this "problem" (it's not unique to doctest) and thought I
> was doing something wrong. I figured doctest's use of docstrings for
> testing would be exemplary, so I tried doctest.
> In a way, doctest *was* exemplary...
> But it seems that its going to be awkward to do interactive
> development in IDLE of modules that employ doctest. That seems a
> shame; routine use of doctest and IDLE would be a good practice.
If you like IDLE enough, you'll eventually <wink> discover workarounds. For
using doctest specifically, and provided you don't intend to exploit the
"Advanced Usage" of merging multiple runs, change your
import doctest, mymodule
blocks by inserting this line in the middle:
doctest.master = None
That explicitly wipes out the only state doctest retains across runs, making
it functionally equivalent to reloading doctest.
More general cases can be approached by writing a little program that
explicitly reloads the modules you need to have reloaded across runs, and
running that from time to time as needed.
This won't be solved in general by magic until someone contributes code to
launch "Run Script" in a fresh process; but that's not always what you'll
it's-life-it-sucks<wink>-ly y'rs - tim
More information about the Python-list