2
0
mirror of https://github.com/mhinz/neovim-remote synced 2024-11-11 13:10:34 +00:00

Test: introduce Nvim class

This commit is contained in:
Marco Hinz 2018-03-12 17:59:16 +01:00
parent 172ee11a13
commit 2e4bf0f836
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F

View File

@ -6,16 +6,29 @@ import signal
import subprocess
import nvr
def test_open_and_write_file():
env = {'NVIM_LISTEN_ADDRESS': '/tmp/pytest_nvimsock'}
env.update(os.environ)
env = {'NVIM_LISTEN_ADDRESS': '/tmp/pytest_nvimsock'}
testfile = '/tmp/pytest_file'
with subprocess.Popen(['nvim', '-nu', 'NORC', '--headless'], close_fds=True,
env=env) as proc:
class Nvim:
nvim = None
def start(self, env={}):
env.update(os.environ)
self.nvim = subprocess.Popen(['nvim', '-nu', 'NORC', '--headless'],
close_fds=True, env=env)
time.sleep(1)
argv = ['nvr', '-c', 'e /tmp/pytest_file | %d | exe "norm! iabc" | w']
nvr.main(argv=argv, env=env)
proc.send_signal(signal.SIGTERM)
def stop(self):
self.nvim.send_signal(signal.SIGTERM)
def test_open_and_write_file():
nvim = Nvim()
nvim.start()
argv = ['nvr', '-c', 'e /tmp/pytest_file | %d | exe "norm! iabc" | w']
nvr.main(argv, env)
nvim.stop()
with open('/tmp/pytest_file') as f:
assert 'abc\n' == f.read()
os.remove(testfile)