Opened 3 years ago

Last modified 3 years ago

#23504 new enhancement

Fast assertions — at Initial Version

Reported by: roed Owned by:
Priority: major Milestone: sage-8.1
Component: misc Keywords: sd87
Cc: saraedum Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:


It would be cool to have an assertion that was possible to turn on and off, and that weren't caught by except Exception. For example:

class Assertion_Error(BaseException):
def assert_(F, msg=None, args=(), kwds={}):
    if not callable(F):
        raise ValueError("Must use a callable")
    if assertions_enabled and not F(*args, **kwds):
        raise AssertionError(msg)

One could probably also have msg be lazy as well...

Change History (0)

Note: See TracTickets for help on using tickets.