[Python-ideas] hookable assertions - to support testing utilities and debugging

Steven D'Aprano steve at pearwood.info
Thu Feb 19 12:05:06 CET 2015


On Thu, Feb 19, 2015 at 08:25:34AM +0100, Ronny Pfannschmidt wrote:
> 
> Hi,
> 
> the idea is to have the assert statement call a global method,
> just like import does
> 
> one could then do something like
[...]

I believe that overloading assert in this fashion is an abuse of assert. 
If we want custom "raise if not this condition" calls, I think we should 
copy unittest and define functions that do what we want, not abuse the 
assert statement.

If you want to (mis)use assert for unit and regression testing, you 
should see the nose third party module and see if that does the sort of 
thing you want.


-- 
Steve


More information about the Python-ideas mailing list