#NEWLINE# def testErrorsInBool( self ) : #NEWLINE# #INDENT# class cm ( object ) : #NEWLINE# #INDENT# def __init__( self , bool_conversion ) : #NEWLINE# #INDENT# class Bool ( ) : #NEWLINE# #INDENT# def __bool__( self ) : #NEWLINE# #INDENT# return bool_conversion ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . exit_result = Bool ( ) #NEWLINE# #UNINDENT# def __enter__( self ) : #NEWLINE# #INDENT# return 3 #NEWLINE# #UNINDENT# def __exit__( self , a , b , c ) : #NEWLINE# #INDENT# return self . exit_result #NEWLINE# #UNINDENT# #UNINDENT# def trueAsBool( ) : #NEWLINE# #INDENT# with cm ( ( lambda : True ) ) : #NEWLINE# #INDENT# self . fail ( 'Should NOT see this' ) #NEWLINE# #UNINDENT# #UNINDENT# trueAsBool ( ) #NEWLINE# def falseAsBool( ) : #NEWLINE# #INDENT# with cm ( ( lambda : False ) ) : #NEWLINE# #INDENT# self . fail ( 'Should raise' ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertRaises ( AssertionError , falseAsBool ) #NEWLINE# def failAsBool( ) : #NEWLINE# #INDENT# with cm ( ( lambda : ( 1 // 0 ) ) ) : #NEWLINE# #INDENT# self . fail ( 'Should NOT see this' ) #NEWLINE# #UNINDENT# #UNINDENT# self . assertRaises ( ZeroDivisionError , self )