Identifying exceptions that can be raised
peter at engcorp.com
Mon Nov 22 14:06:04 CET 2004
Roy Smith wrote:
> Peter Hansen <peter at engcorp.com> wrote:
> What you are describing is essentially black-box testing. It may be a
> valid procedure for QA purposes, but it's hardly a reasonable way to
> write a program.
You provide nothing to back up this claim.
> Actually, it's worse than black-box testing.
Nor this, of course.
> Black-box testing says you should design your tests based only on the
> documentation (functional spec, whatever) without looking at the source
> code. You're saying you should write the code without even looking at
> the documentation.
Did I say that somewhere? I really don't think you can
find anything in what I said that equates to me recommending
that one should write code this way in the general case.
> Close the file. A closed file cannot be read or written any more. Any
> operation which requires that the file be open will raise a ValueError
> after the file has been closed. Calling close() more than once is
In other words, the documentation in this case happens to align
with the actual behaviour of file objects.
Now I ask you, how often does documentation either not mention
the fact at all (which was the topic of this thread until now),
or -- perhaps less common with standard library code, but widespread
with other code -- mention things that are inaccurate and wrong?
And how often does the code actually behave the way the code
In other words, which should one trust more, the documentation
or the actual observed behaviour?
> Computer Science is not an experimental science.
Again, you've said nothing that in any way justifies this statement.
I'm not saying CS _is_ an experimental science, but I think
I would say that your implied statement that one should *never*
do this is fundamentally flawed.
Ultimately, however, this is a silly argument, because neither
you nor I write code solely in the manner I described, nor
in the manner you appear to be recommending (i.e. going exclusively
based on the documentation), so I'm not even sure why you
As a final note, I'll point out that I was writing code for
a mock file system, and if you think doing that solely based
on the documentation is a good idea, I heartily recommend you
give it a go and see how useful your results actually are...
More information about the Python-list