isA function?

Peter Hansen peter at engcorp.com
Mon Jul 15 19:33:21 EDT 2002


"Delaney, Timothy" wrote:
> 
> > From: Peter Hansen [mailto:peter at engcorp.com]
> >
> > have the right signature is inadequate in this circumstance, though
> > it may be acceptable for you when doing traditional unit testing,
> > writing tests after the fact.
> 
> Lovely indirect insult there Peter. Incorrect (beyond the fact that in Java,
> which my current project uses, you need a minimal amount of code written
> before the unit test can be completely written) but lovely nonetheless.

Incorrect?  Okay, if you say the signature is inadequate *even* in traditional 
unit testing, I'll take your word for it (as I'd never done much unit
testing until learning about test-driven development).

As for indirect insult -- I don't understand why you think that, unless
you find "traditional" insulting -- but in any case I didn't mean
it to be insulting, indirect or otherwise.  Apparently my writing style
frequently causes people to think that (apart from the times when I 
*do* intend to insult), for which I apologize.  I'm trying to improve.

> Agreed - in the factory case, a single test of each input -> output is
> necessary (one case where a type check is a good idea - immediately
> knowledge that you haven't got what you expect).

Okay, so we both agree on that.  I was under the impression you were
adamantly against such a test in all cases, even after I first presented
that example two posts back.  I must have misunderstood again, and once
more I apologize.

> Apart from that one location though, I stick by not doing typechecks in unit
> tests - objects should pass behaviour tests. It's actually a lot easier to
> write unit tests that do this, rather than checking for type - it means that
> your class heirarchy (if any) can change as required and your unit tests
> still ensure that the behaviour is correct.

Agreed!  I don't believe I've ever used a type test in any of my unit
tests so far, and certainly not much in real code (or perhaps at all).
I doubt either Roy or I would defend such a practice in most cases,
so we seem to all be in agreement after all.

-Peter



More information about the Python-list mailing list