PEP 3107 and stronger typing (note: probably a newbie question)

Paul Rubin http
Wed Jul 4 10:22:45 CEST 2007

greg <greg at> writes:
> > E.g. your program might pass its test and run properly for years
> > before some weird piece of input data causes some regexp to not quite
> > work.
> Then you get a bug report, you fix it, and you add a test
> for it so that particular bug can't happen again.

Why on earth would anyone prefer taking a failure in the field over
having a static type check make that particular failure impossible?

> > Once I got the function to work, I deployed it without writing
> > permanent tests for it.
> That suggests you had a temporary test at some point.

I ran the function on real, dynamic data and made sure the results
were right.

> So, keep it and make it a permanent test. Even if it's just a small
> manually-created directory, it's still better than nothing, and you
> can add to it over time to cover any bugs that turn up.

That doesn't obviously fit into the doctest framework; such a test
would be considerably more complex than the function itself, and the
types of situations that I could imagine causing failures wouldn't be
included in a test like that.  Basically I had to get on to the next
thing.  Given the somewhat throwaway nature of this particular code,
nothing else really made sense.  But I think I'm going to look into
using dejagnu for more heavyweight testing of some other parts of the
program, so I guess some good came out of discussing this issue.

More information about the Python-list mailing list