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

Function MockCompletionRequest

python/ycm/tests/completion_test.py:38–54  ·  view source on GitHub ↗

Mock out the CompletionRequest, replacing the response handler JsonFromFuture with the |response_method| parameter.

( response_method )

Source from the content-addressed store, hash-verified

36
37@contextlib.contextmanager
38def MockCompletionRequest( response_method ):
39 """Mock out the CompletionRequest, replacing the response handler
40 JsonFromFuture with the |response_method| parameter."""
41
42 # We don't want the requests to actually be sent to the server, just have it
43 # return success.
44 with patch( 'ycm.client.completer_available_request.'
45 'CompleterAvailableRequest.PostDataToHandler',
46 return_value = True ):
47 with patch( 'ycm.client.completion_request.CompletionRequest.'
48 'PostDataToHandlerAsync',
49 return_value = MagicMock( return_value=True ) ):
50
51 # We set up a fake response.
52 with patch( 'ycm.client.base_request._JsonFromFuture',
53 side_effect = response_method ):
54 yield
55
56
57@contextlib.contextmanager

Calls

no outgoing calls

Tested by

no test coverage detected