Skip to content

Commit

Permalink
Auto merge of #2701 - micbou:rewrite-omnifunc-tests, r=Valloric
Browse files Browse the repository at this point in the history
[READY] Rewrite omnifunc tests

Change the `VimBuffer` object to accept a Python function as its omnifunc, e.g.
```python
def Omnifunc( findstart, base ):
  if findstart:
    return 5
  return [ 'a', 'b', 'c' ]
```
and rewrite the omnifunc tests accordingly. This reduces the amount of mocking done directly in these tests.

Also, extend the `ToBytesOnPY2` function to lists and dictionaries so that, instead of having to write
```python
[ ToBytesOnPY2( 'a' ), ToBytesOnPY2( 'b' ), ToBytesOnPY2( 'c' ) ]
```
in tests, one can write:
```python
ToBytesOnPY2( [ 'a', 'b', 'c' ] )
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2701)
<!-- Reviewable:end -->
  • Loading branch information
zzbot authored Jul 6, 2017
2 parents 191b79e + db0b9ab commit c9be11a
Show file tree
Hide file tree
Showing 3 changed files with 565 additions and 613 deletions.
8 changes: 4 additions & 4 deletions python/ycm/tests/event_notification_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with CurrentWorkingDirectory( unicode_dir ):
with MockVimBuffers( [ current_buffer ], current_buffer, ( 6, 5 ) ):
with MockVimBuffers( [ current_buffer ], current_buffer, ( 1, 5 ) ):
ycm.OnFileReadyToParse()

assert_that(
Expand All @@ -370,7 +370,7 @@ def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
contains(
has_entries( {
'filepath': current_buffer_file,
'line_num': 6,
'line_num': 1,
'column_num': 6,
'file_data': has_entries( {
current_buffer_file: has_entries( {
Expand Down Expand Up @@ -416,7 +416,7 @@ def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test(
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with MockVimBuffers( [ current_buffer, modified_buffer, unmodified_buffer ],
current_buffer,
( 3, 5 ) ):
( 1, 5 ) ):
ycm.OnBufferVisit()

assert_that(
Expand All @@ -425,7 +425,7 @@ def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test(
contains(
has_entries( {
'filepath': current_buffer_file,
'line_num': 3,
'line_num': 1,
'column_num': 6,
'file_data': has_entries( {
current_buffer_file: has_entries( {
Expand Down
Loading

0 comments on commit c9be11a

Please sign in to comment.