I won't propose a syntax, but I think it would be useful if *assert* could
raise an exception different from *AssertionError*.

This is in the context of "Design by contrast" (DBC) as a useful companion
to "Test-driven development" and other forms of external tests.

Basically, the proposal is to allow for an exception type and value to be
specified in *assert*, instead of the customary:

if not assertion:

    raise ValueError('a message')


Perhaps the assertion would not go away with *-OO* when an exception type
is specified?

>From my experience, assertions are useful in most non-trivial cases, and
should be there on any complex case. Perhaps we'd use more assertions if
they become easier to use and more customizable?

The agile trend has been in favor of external tests (like unit tests). I
think that we should not forget about the value of software that verifies
its state at runtime through assertions.

An SO reference to the basic inquiry:

https://stackoverflow.com/questions/1569049/making-pythons-assert-throw-an-exception-that-i-choose


-- 
Juancarlo *Añez*
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KIREHCFXUS6Z7TCE7UBFNANQFEOHMHUB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to