Skip to content

Commit

Permalink
python2: fix buffer inequality operation #400
Browse files Browse the repository at this point in the history
Fix #398

Also fix warning in test_buffer.py:96:
DeprecationWarning: invalid escape sequence \s
    assert vim.options['define'] == '^\s*#\s*define'
  • Loading branch information
noelevans authored and justinmk committed Jun 22, 2019
1 parent 4dd9962 commit 58ff62f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pynvim/api/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def __delitem__(self, idx):
"""
self.__setitem__(idx, None)

def __ne__(self, other):
""" Test inequality of Buffers.
Necessary for Python 2 compatibility """
return not self.__eq__(other)

def append(self, lines, index=-1):
"""Append a string or list of lines to the buffer."""
if isinstance(lines, (basestring, bytes)):
Expand Down
8 changes: 7 additions & 1 deletion test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_options(vim):
vim.current.buffer.options['define'] = 'test'
assert vim.current.buffer.options['define'] == 'test'
# Doesn't change the global value
assert vim.options['define'] == '^\s*#\s*define'
assert vim.options['define'] == r'^\s*#\s*define'


def test_number(vim):
Expand Down Expand Up @@ -172,3 +172,9 @@ def test_update_highlights(vim):
vim.current.buffer[:] = ['a', 'b', 'c']
src_id = vim.new_highlight_source()
vim.current.buffer.update_highlights(src_id, [["Comment", 0, 0, -1], ("String", 1, 0, 1)], clear=True, async_=False)


def test_buffer_inequality(vim):
b = vim.current.buffer
assert not (b != vim.current.buffer)

0 comments on commit 58ff62f

Please sign in to comment.