Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: remove cleanup_func #414

Merged
merged 2 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import os
import textwrap

import pytest

Expand All @@ -9,50 +8,6 @@
pynvim.setup_logging("test")


@pytest.fixture(autouse=True)
def cleanup_func(vim):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave a stub here (with pass)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I want to add setup code later it will be a pain to find out how. Stubs don't hurt anything.

Not a blocker though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stubs at least get called all the time (not really that bad, but still).
Should be discoverable through the Git history I think.
(and if you're used to pytest you would know what you need anyway)

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.command(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')
Expand Down
2 changes: 1 addition & 1 deletion test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def test_repr(vim):
assert repr(vim.current.buffer) == "<Buffer(handle=2)>"
assert repr(vim.current.buffer) == "<Buffer(handle=1)>"


def test_get_length(vim):
Expand Down
2 changes: 1 addition & 1 deletion test/test_tabpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def test_number(vim):


def test_repr(vim):
assert repr(vim.current.tabpage) == "<Tabpage(handle=2)>"
assert repr(vim.current.tabpage) == "<Tabpage(handle=1)>"
4 changes: 3 additions & 1 deletion test/test_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def test_command_error(vim):
def test_eval(vim):
vim.command('let g:v1 = "a"')
vim.command('let g:v2 = [1, 2, {"v3": 3}]')
assert vim.eval('g:') == {'v1': 'a', 'v2': [1, 2, {'v3': 3}]}
g = vim.eval('g:')
assert g['v1'] == 'a'
assert g['v2'] == [1, 2, {'v3': 3}]


def test_call(vim):
Expand Down
2 changes: 1 addition & 1 deletion test/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ def test_handle(vim):


def test_repr(vim):
assert repr(vim.current.window) == "<Window(handle=1001)>"
assert repr(vim.current.window) == "<Window(handle=1000)>"