Assert that an exception of type \var{exceptionType} is thrown when the function \var{f} is evaluated.
( exceptionType, f, msg = None )
| 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 ) |
no test coverage detected