mirror of
https://github.com/gryf/pythonhelper.git
synced 2025-12-18 20:10:24 +01:00
Bugfix and move plugin to python specific ftplugin
Move to python specific plugin (ftplugin), Fixed bug regarding empty buffer.
This commit is contained in:
@@ -151,7 +151,11 @@ class PythonHelper(object):
|
||||
line_number = vim.current.window.cursor[0] - 1
|
||||
|
||||
while True:
|
||||
line = vim.current.buffer[line_number]
|
||||
try:
|
||||
line = vim.current.buffer[line_number]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
line_indent = len(RE_INDENT.match(line).group(1))
|
||||
if line.strip():
|
||||
break
|
||||
@@ -17,8 +17,7 @@ class Window(object):
|
||||
|
||||
class Current(object):
|
||||
def __init__(self):
|
||||
with open('test_py_example.py') as fobj:
|
||||
self.buffer = fobj.read().split('\n')
|
||||
self.buffer = []
|
||||
self.window = Window()
|
||||
|
||||
|
||||
@@ -26,6 +25,9 @@ class MockVim(object):
|
||||
current = Current()
|
||||
command = Command()
|
||||
|
||||
with open('test_py_example.py') as fobj:
|
||||
BUFFER = fobj.read().split('\n')
|
||||
|
||||
|
||||
sys.modules['vim'] = vim = MockVim
|
||||
|
||||
@@ -33,8 +35,22 @@ sys.modules['vim'] = vim = MockVim
|
||||
import pythonhelper
|
||||
|
||||
|
||||
class TestTagsHelperWithEmptyBuffer(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
vim.current.buffer = []
|
||||
|
||||
def test_get_tag(self):
|
||||
vim.current.window.cursor = (1, 1)
|
||||
tag = pythonhelper.PythonHelper._get_tag(1, 2)
|
||||
self.assertIsNone(tag)
|
||||
|
||||
|
||||
class TestTagsHelper(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
vim.current.buffer = BUFFER
|
||||
|
||||
def test_import(self):
|
||||
vim.current.window.cursor = (1, 1)
|
||||
tag = pythonhelper.PythonHelper._get_tag(1, 2)
|
||||
Reference in New Issue
Block a user