MCPcopy Create free account
hub / github.com/ycm-core/YouCompleteMe / MockAsyncServerResponseInProgress

Function MockAsyncServerResponseInProgress

python/ycm/tests/mock_utils.py:80–93  ·  view source on GitHub ↗

Return a fake future object that is incomplete. Suitable for mocking a response future within a client request. For example: with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 1 ) ) as v: mock_response = MockAsyncServerResponseInProgress() with patch.dict( ycm._message_po

()

Source from the content-addressed store, hash-verified

78
79
80def MockAsyncServerResponseInProgress():
81 """Return a fake future object that is incomplete. Suitable for mocking a
82 response future within a client request. For example:
83
84 with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 1 ) ) as v:
85 mock_response = MockAsyncServerResponseInProgress()
86 with patch.dict( ycm._message_poll_requests, {} ):
87 ycm._message_poll_requests[ filetype ] = MessagesPoll( v.current.buffer )
88 ycm._message_poll_requests[ filetype ]._response_future = mock_response
89 # Needed to keep a reference to the mocked dictionary
90 mock_future = ycm._message_poll_requests[ filetype ]._response_future
91 ycm.OnPeriodicTick() # Uses ycm._message_poll_requests[ filetype ] ...
92 """
93 return mock.MagicMock( wraps = FakeFuture( False ) )
94
95
96def MockAsyncServerResponseException( exception ):

Calls 1

FakeFutureClass · 0.85