Develop-test-debug cycle

John Roth johnroth at ameritech.net
Thu Mar 21 19:03:23 EST 2002


"Dale Strickland-Clark" <dale at riverhall.NOTHANKS.co.uk> wrote in message
news:un2h9ukh13kddcd3ooc9osejapiaf5v6t3 at 4ax.com...
> I can't believe I'm doing this this best way.
>
> I am debugging a large system written in Python with modules spread
> over 4 directories. I'm using PythonWin under Win2K to set-up the
> environment and run the code.
>
> Setting up the environment typically involves the following commands:
>
> import sys
> sys.path.append("x:\\whereever")
> from wibbleModule import wibble
> wibs = wibble(args)
>
> wibs.methods(args)
>
> <error...>
>
> At this point, I fix the error.
>
> Now, I haven't figured out a way of continueing past this point
> without quiting and starting from scratch because there appears to be
> no way to get Python to reload a module. The reload() function doesn't
> do it.
>
> I've tried stuff like this:
>
> del wibs
> reload(sys.modules['wibbleModule']
>
> but I still seem to have the old version loaded.
>
> I've also tried using PyCrust for this but it suffers from the same
> problems. I assume IDLE does too.
>
> How do others go about interactively debugging large Python OO-based
> systems?

I don't. I got bit by the XP bug a while back, and now I
write all unit tests in advance, using the 'unittest' module.
I keep the editor (PythonWin) open, save the module
I've just changed, and invoke a script at the command line
to run the current test set. Works like a charm, and has the
additional advantage that I don't have to worry about
breaking things with changes - the unit tests are persistant,
so they'll tell me.

I don't have to go into the debugger very much to figure
out a problem, so reloading the module from scratch
isn't a significant issue.

John Roth
>
> Thanks for any pointers.
> --
> Dale Strickland-Clark
> Riverhall Systems Ltd





More information about the Python-list mailing list