[Python-Dev] Unit testing (again)

Jeremy Hylton jeremy@alum.mit.edu
Mon, 12 Feb 2001 22:15:30 -0500 (EST)


>>>>> "FL" == Fredrik Lundh <fredrik@effbot.org> writes:

  FL> Jeremy wrote:
  >> I know that Quixote uses test cases in strings, but it's the
  >> thing I like the least about Quixote unittest

  FL> like whitespace indentation, it's done that way for a reason.

Whitespace indentation is natural and makes code easier to read.
Putting little snippets of Python code in string literals passed to
exec has the opposite effect.

doctest is a nice middle ground, because the code snippets are in a
natural setting -- an interactive interpreter setting.

  >> I'm not sure how to achieve this or why you would want the test
  >> to continue.

  FL> same reason you want your compiler to report more than just the
  FL> first error -- so you can see patterns in the test script's
  FL> behaviour, so you can fix more than one bug at a time, or fix
  FL> the bugs in an order that suits you and not the framework, etc.

Python's compiler only reports one syntax error for a source file,
regardless of how many it finds <0.5 wink>.

  >> After the first exception, something is broken and needs to be
  >> fixed, regardless of whether subsequent lines of code work.

  FL> jeremy, that's the kind of comment I would have expected from a
  FL> manager, not from a programmer who has done lots of testing.

I don't think there's any reason to be snide.

The question is one of granularity:  At what level of granularity
should the test framework catch exceptions and continue?  I'm
satisfied with the unit of testing being a method.

Jeremy