Debugging Python

Peter Hansen peter at
Mon Jan 12 15:26:35 CET 2004

Alan Gauld wrote:
> On Fri, 9 Jan 2004 10:29:46 GMT, Harry George
> < at> wrote:
> > > I'm not sure about others, but when I design and code using test-driven
> > > development (TDD), I tend not to need to debug almost ever.
> > told him almost exactly what you said: If you are doing test-based
> > (whether or not it is with someojne else and thus Agile), you don't
> > get into those grim debug sessions that are part of life in C/C++
> > land.
> Interesting comments. How do people generally perform these tests
> then? My primary test tool, for low level testing, is usually the
> debugger. Batch mode debugging is something I've been doing since
> I worked on VAX/VMS systems and its seems as natural as breathing
> to me. Its easy to save a test session and run it later etc. How
> else do you test code at a low level?
> Or does using the debugger as a test harness not count as
> debugging?

The debugger-as-test-harness does not count as testing, anyway, at
least not in the Agile sense.  The tests *must* be automated, and
run very frequently (constantly) or you can't be very agile.

As others have said, the unittest is the key (in Python) or at least
the de facto standard.  I would not agree that using it is "tedious"
at all, however, as it takes me only about twenty seconds to start a
new test file and that's *without* using a template.  Running the tests
is also not tedious, at least not if you invest a few hours in a 
simple utility that automates even the run-all-tests functionality.
I just type "unit -a" and all tests in all subfolders are immediately
run, without output going to a log file for later analysis in case
there are failures.


More information about the Python-list mailing list