#NEWLINE# def test_close_while_accepted( self ) : #NEWLINE# #INDENT# rmock = Mock ( ) #NEWLINE# rmock . return_value = sentinel . msg #NEWLINE# cacmock = Mock ( ) #NEWLINE# transport = Mock ( ) #NEWLINE# self . ch . recv = rmock #NEWLINE# self . ch . _recv_queue . await_n = MagicMock ( ) #NEWLINE# self . ch . _create_accepted_channel = cacmock #NEWLINE# self . ch . on_channel_open ( transport ) #NEWLINE# self . ch . _fsm . current_state = self . ch . S_ACTIVE #NEWLINE# self . ch . _consuming = True #NEWLINE# self . ch . close_impl = Mock ( ) #NEWLINE# self . ch . _on_stop_consume = Mock ( ) #NEWLINE# retch = self . ch . accept ( ) #NEWLINE# self . assertEquals ( self . ch . _fsm . current_state , self . ch . S_ACCEPTED ) #NEWLINE# self . ch . close ( ) #NEWLINE# self . assertFalse ( self . ch . close_impl . called ) #NEWLINE# self . assertFalse ( self . ch . _on_stop_consume . called ) #NEWLINE# self . assertEquals ( retch . ch . _fsm . current_state , self . ch . S_CLOSING ) #NEWLINE# self . ch . exit_accept ( ) #NEWLINE# self . assertTrue ( self . ch . close_impl . called ) #NEWLINE# self . assertTrue ( self . ch . _on_stop_consume . called ) #NEWLINE# self . assertEquals ( self . ch . _fsm . current_state , self . ch . S_CLOSED ) #NEWLINE# self . assertFalse ( self . ch . _consuming )