"assert" annoyance

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Jun 22 10:55:49 CEST 2007

Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:

> So I have some assert statements in my code to verify the absence of
> some "impossible" conditions.  They were useful in debugging and of
> course I left them in place for "real" runs of the program.  Umpteen
> hours into a run, an assertion failed, and of course since failure
> was "impossible", I didn't catch the exception so the whole program
> crashed.

This is exactly the sort of check which is best done as unit
tests. The program has no 'assert' cruft in it, and the tests can be
as comprehensive as needed without having any impact on the actual
running program.

 \         Legionnaire: "We have their leader captive!"  C泡r: "Is he |
  `\    bound?"  Legionnaire: "Of his health I know not, sir."  -- The |
_o__)                    Goon Show, _The Histories Of Pliny The Elder_ |
Ben Finney

More information about the Python-list mailing list