#NEWLINE# @ patch ( 'ws4py.manager.SelectPoller' ) #NEWLINE# def test_cannot_remove_unregistered_websocket( self , MockSelectPoller ) : #NEWLINE# #INDENT# m = WebSocketManager ( poller = MockSelectPoller ( ) ) #NEWLINE# ws = MagicMock ( ) #NEWLINE# ws . sock . fileno . return_value = 1 #NEWLINE# m . remove ( ws ) #NEWLINE# self . assertEqual ( len ( m ) , 0 ) #NEWLINE# self . assertFalse ( m . poller . unregister . called ) #NEWLINE# m . add ( MockSelectPoller ) #NEWLINE# self . assertEqual ( len ( m ) , 1 ) #NEWLINE# m . remove ( ws ) #NEWLINE# self . assertEqual ( len ( m ) , 0 ) #NEWLINE# m . poller . unregister . assert_called_once_with ( 1 ) #NEWLINE# m . poller . reset_mock ( ) #NEWLINE# m . remove ( ws ) #NEWLINE# self . assertEqual ( len ( m ) , 0 ) #NEWLINE# self . assertFalse ( m . poller . unregister . called )