#NEWLINE# def test_teardown_closes_out_stubs_and_mocks( self ) : #NEWLINE# #INDENT# class Stub ( object ) : #NEWLINE# #INDENT# calls = 0 #NEWLINE# def teardown( self ) : #NEWLINE# #INDENT# self . calls += 1 #NEWLINE# #UNINDENT# #UNINDENT# obj = type ( 'test' , ( object , ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ( ) #NEWLINE# setattr ( obj , 'mock1' , 'foo' ) #NEWLINE# setattr ( obj , 'mock2' , 'bar' ) #NEWLINE# case = CupOf ( ) #NEWLINE# stub = Stub ( ) #NEWLINE# case . _stubs = deque ( [ stub ] ) #NEWLINE# case . _mocks = deque ( [ ( obj , 'mock1' , 'fee' ) , ( obj , 'mock2' ) ] ) #NEWLINE# case . teardown ( ) #NEWLINE# self . assertEquals ( 1 , stub . calls ) #NEWLINE# self . assertEquals ( 'fee' , obj . mock1 ) #NEWLINE# self . assertFalse ( hasattr ( obj , 'mock2' ) )