MCPcopy Create free account
hub / github.com/ActiveState/code / assertException

Function assertException

recipes/Python/577482_Easy_property/recipe-577482.py:266–276  ·  view source on GitHub ↗

Assert that an exception of type \var{exceptionType} is thrown when the function \var{f} is evaluated.

( exceptionType, f, msg = None )

Source from the content-addressed store, hash-verified

264 traceback.print_stack()
265
266 def assertException( exceptionType, f, msg = None ):
267 """Assert that an exception of type \var{exceptionType}
268 is thrown when the function \var{f} is evaluated.
269 """
270 try:
271 f()
272 except exceptionType:
273 assert True
274 else:
275 print >>sys.stderr, "Error: expected <%s> to be thrown by function%s" % ( exceptionType.__name__, colon( msg ) )
276 traceback.print_stack()
277
278 def assertNone( x, msg = None ):
279 assertSame( None, x, msg )

Callers 2

TestClass · 0.70
recipe-577482.pyFile · 0.70

Calls 2

colonFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected