isA function?

Delaney, Timothy tdelaney at avaya.com
Mon Jul 15 18:39:25 EDT 2002


> 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.

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).

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.

Tim Delaney





More information about the Python-list mailing list