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

Ronny Pfannschmidt opensource at ronnypfannschmidt.de
Thu Feb 19 08:25:34 CET 2015


Hi,

the idea is to have the assert statement call a global method,
just like import does

one could then do something like

with exception.collect_assertions:
 assert myobj.foo is bar
 assert myobj.baz == 123

on order to do groups of assertions having more debugging information on 
failed assertions

it could also enable more interesting context managers like 

with testtool.fail_lazy:
 ...  # this would fail the test but not stop its exeution in the middle

with testtools.informative_assert:
  ...  # this will get logged but the test run wont be considered failed


More information about the Python-ideas mailing list