#NEWLINE# def testNestedExceptionBeforeInnerStatement( self ) : #NEWLINE# #INDENT# mock_a = mock_contextmanager_generator ( ) #NEWLINE# mock_b = mock_contextmanager_generator ( ) #NEWLINE# self . bar = None #NEWLINE# def shouldThrow( ) : #NEWLINE# #INDENT# with mock_a as self . foo : #NEWLINE# #INDENT# self . assertInWithManagerInvariants ( mock_a ) #NEWLINE# self . assertInWithGeneratorInvariants ( self . foo ) #NEWLINE# self . raiseTestException ( ) #NEWLINE# with mock_b as self . bar : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . assertRaises ( RuntimeError , shouldThrow ) #NEWLINE# self . assertAfterWithManagerInvariantsWithError ( mock_a ) #NEWLINE# self . assertAfterWithGeneratorInvariantsWithError ( self . foo ) #NEWLINE# self . assertEqual ( self . bar , None ) #NEWLINE# self . assertFalse ( mock_b . enter_called ) #NEWLINE# self . assertFalse ( mock_b . exit_called ) #NEWLINE# self . assertEqual ( mock_b . exit_args , None )