$OpenBSD: patch-test_conftest_py,v 1.1 2018/07/01 14:21:36 edd Exp $

Although this file is present in the upstream source tree, it was not
included when the release tarball was created.  This file is needed to
run unit tests and was copied from the release tag matching this
version.

Index: test/conftest.py
--- test/conftest.py.orig
+++ test/conftest.py
@@ -0,0 +1,67 @@
+import json
+import os
+import textwrap
+
+import neovim
+import pytest
+
+neovim.setup_logging("test")
+
+
+@pytest.fixture(autouse=True)
+def cleanup_func(vim):
+    fun = textwrap.dedent(''':function BeforeEachTest()
+        set all&
+        redir => groups
+        silent augroup
+        redir END
+        for group in split(groups)
+            exe 'augroup '.group
+            autocmd!
+            augroup END
+        endfor
+        autocmd!
+        tabnew
+        let curbufnum = eval(bufnr('%'))
+        redir => buflist
+        silent ls!
+        redir END
+        let bufnums = []
+        for buf in split(buflist, '\\n')
+            let bufnum = eval(split(buf, '[ u]')[0])
+            if bufnum != curbufnum
+            call add(bufnums, bufnum)
+            endif
+        endfor
+        if len(bufnums) > 0
+            exe 'silent bwipeout! '.join(bufnums, ' ')
+        endif
+        silent tabonly
+        for k in keys(g:)
+            exe 'unlet g:'.k
+        endfor
+        filetype plugin indent off
+        mapclear
+        mapclear!
+        abclear
+        comclear
+        endfunction
+    ''')
+    vim.input(fun)
+    vim.command('call BeforeEachTest()')
+    assert len(vim.tabpages) == len(vim.windows) == len(vim.buffers) == 1
+
+
+@pytest.fixture
+def vim():
+    child_argv = os.environ.get('NVIM_CHILD_ARGV')
+    listen_address = os.environ.get('NVIM_LISTEN_ADDRESS')
+    if child_argv is None and listen_address is None:
+        child_argv = '["nvim", "-u", "NONE", "--embed"]'
+
+    if child_argv is not None:
+        editor = neovim.attach('child', argv=json.loads(child_argv))
+    else:
+        editor = neovim.attach('socket', path=listen_address)
+
+    return editor
