[Python-Dev] Unit testing (again)
Fredrik Lundh
fredrik@pythonware.com
Tue, 13 Feb 2001 17:58:14 +0100
jeremy wrote:
> 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.
Only if you're using large snippets.
...just like whitespace indentation makes things harder it
you're mixing tabs and spaces, or prints a file with the wrong
tab setting, or cuts and pastes code between editors with
different tab settings.
In both cases, the solution is simply "don't do that"
> doctest is a nice middle ground, because the code snippets are in a
> natural setting -- an interactive interpreter setting.
They're still inside a string...
> Python's compiler only reports one syntax error for a source file,
> regardless of how many it finds <0.5 wink>.
Sure, but is that because user testing has shown that Python
programmers (unlike e.g. C programmers) prefer to see only one
bug at a time, or because it's convenient to use exceptions also
for syntax errors? Would a syntax-checking editor be better if
it only showed one syntax error, even if it found them all?
> > 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.
Well, I first wrote "taken out of context, that's the kind of comment"
but then I noticed that it wasn't really taken out of context.
And in full context, it still looks a bit arrogant: why would Andrew
raise this issue if *he* didn't want more granularity?
:::
But having looked everything over one more time, and having ported
a small test suite to doctest.py, I'm now -0 on adding more test frame-
works to 2.1. If it's good enough for tim...
(and -1 if adding more frameworks means that I have to use them ;-).
Cheers /F