Testing dynamic languages

grkuntzmd at gmail.com grkuntzmd at gmail.com
Sat Apr 4 09:37:44 EDT 2009


I am a Java developer. There, I said it :-).

When I am writing code, I can  rely on the compiler to confirm that
any methods I write will be called with parameters of the "right"
type. I do not need to test that parameter #1 really is a String
before I call some method on it that only works on Strings.

If I am writing in Python, since it is dynamically, but strongly
typed, I really should check that each parameter is of the expected
type, or at least can respond to the method I plan on calling ("duck"
typing). Every call should be wrapped in a try/except statement to
prevent the method (and program) from crashing when my method is
called with an integer instead of the expected string.

Is this the experience that Python programmer (of large projects) see?
Do you also write unit tests to confirm that the methods actually
check for and catch "bad" parameter types? If I am writing small one-
off scripts, I wouldn't worry about it, but if I am writing a large
system that must have 99+% uptime without constant monitoring, this
really should be verified.

Up for discussion...



More information about the Python-list mailing list