From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/provider/python3_spec.lua | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'test/functional/provider/python3_spec.lua') diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua index d9c44c3315..8d81b86c9c 100644 --- a/test/functional/provider/python3_spec.lua +++ b/test/functional/provider/python3_spec.lua @@ -20,7 +20,10 @@ do matches(expected, pcall_err(command, 'py3 print("foo")')) matches(expected, pcall_err(command, 'py3file foo')) end) - pending(string.format('Python 3 (or the pynvim module) is broken/missing (%s)', reason), function() end) + pending( + string.format('Python 3 (or the pynvim module) is broken/missing (%s)', reason), + function() end + ) return end end @@ -41,25 +44,33 @@ describe('python3 provider', function() it('python3_execute', function() command('python3 vim.vars["set_by_python3"] = [100, 0]') - eq({100, 0}, eval('g:set_by_python3')) + eq({ 100, 0 }, eval('g:set_by_python3')) end) it('does not truncate error message <1 MB', function() -- XXX: Python limits the error name to 200 chars, so this test is -- mostly bogus. local very_long_symbol = string.rep('a', 1200) - feed_command(':silent! py3 print('..very_long_symbol..' b)') + feed_command(':silent! py3 print(' .. very_long_symbol .. ' b)') -- Error message will contain this (last) line. - matches(string.format(dedent([[ + matches( + string.format( + dedent([[ ^Error invoking 'python_execute' on channel 3 %%(python3%%-script%%-host%%): File "", line 1 print%%(%s b%%) %%C* - SyntaxError: invalid syntax%%C*$]]), very_long_symbol), eval('v:errmsg')) + SyntaxError: invalid syntax%%C*$]]), + very_long_symbol + ), + eval('v:errmsg') + ) end) it('python3_execute with nested commands', function() - command([[python3 vim.command('python3 vim.command("python3 vim.command(\'let set_by_nested_python3 = 555\')")')]]) + command( + [[python3 vim.command('python3 vim.command("python3 vim.command(\'let set_by_nested_python3 = 555\')")')]] + ) eq(555, eval('g:set_by_nested_python3')) end) @@ -70,7 +81,7 @@ describe('python3 provider', function() line3 line4]]) feed('ggjvj:python3 vim.vars["range"] = vim.current.range[:]') - eq({'line2', 'line3'}, eval('g:range')) + eq({ 'line2', 'line3' }, eval('g:range')) end) it('py3file', function() @@ -102,7 +113,7 @@ describe('python3 provider', function() describe('py3eval()', function() it('works', function() - eq({1, 2, {['key'] = 'val'}}, funcs.py3eval('[1, 2, {"key": "val"}]')) + eq({ 1, 2, { ['key'] = 'val' } }, funcs.py3eval('[1, 2, {"key": "val"}]')) end) it('errors out when given non-string', function() @@ -131,7 +142,7 @@ describe('python3 provider', function() command 'set pyxversion=3' -- no error eq('Vim(set):E474: Invalid argument: pyxversion=2', pcall_err(command, 'set pyxversion=2')) command 'set pyxversion=0' -- allowed, but equivalent to pyxversion=3 - eq(3, eval'&pyxversion') + eq(3, eval '&pyxversion') end) it('RPC call to expand("") during BufDelete #5245 #5617', function() @@ -146,7 +157,7 @@ describe('python3 provider', function() autocmd BufDelete * python3 foo() autocmd BufUnload * python3 foo()]=]) feed_command("exe 'split' tempname()") - feed_command("bwipeout!") + feed_command('bwipeout!') feed_command('help help') assert_alive() end) -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/provider/python3_spec.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/functional/provider/python3_spec.lua') diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua index 8d81b86c9c..1419d7f651 100644 --- a/test/functional/provider/python3_spec.lua +++ b/test/functional/provider/python3_spec.lua @@ -8,7 +8,7 @@ local source = helpers.source local missing_provider = helpers.missing_provider local matches = helpers.matches local pcall_err = helpers.pcall_err -local funcs = helpers.funcs +local fn = helpers.fn local dedent = helpers.dedent do @@ -113,7 +113,7 @@ describe('python3 provider', function() describe('py3eval()', function() it('works', function() - eq({ 1, 2, { ['key'] = 'val' } }, funcs.py3eval('[1, 2, {"key": "val"}]')) + eq({ 1, 2, { ['key'] = 'val' } }, fn.py3eval('[1, 2, {"key": "val"}]')) end) it('errors out when given non-string', function() @@ -166,11 +166,11 @@ end) describe('python2 feature test', function() -- python2 is not supported, so correct behaviour is to return 0 it('works', function() - eq(0, funcs.has('python2')) - eq(0, funcs.has('python')) - eq(0, funcs.has('python_compiled')) - eq(0, funcs.has('python_dynamic')) - eq(0, funcs.has('python_dynamic_')) - eq(0, funcs.has('python_')) + eq(0, fn.has('python2')) + eq(0, fn.has('python')) + eq(0, fn.has('python_compiled')) + eq(0, fn.has('python_dynamic')) + eq(0, fn.has('python_dynamic_')) + eq(0, fn.has('python_')) end) end) -- cgit From eb5d15e3838f53e2fcd25989c88db87458e9f984 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 7 Jan 2024 13:05:03 +0100 Subject: refactor: rewrite python provider in lua --- test/functional/provider/python3_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/provider/python3_spec.lua') diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua index 1419d7f651..9bde57f777 100644 --- a/test/functional/provider/python3_spec.lua +++ b/test/functional/provider/python3_spec.lua @@ -13,7 +13,7 @@ local dedent = helpers.dedent do clear() - local reason = missing_provider('python3') + local reason = missing_provider('python') if reason then it(':python3 reports E319 if provider is missing', function() local expected = [[Vim%(py3.*%):E319: No "python3" provider found.*]] -- cgit From 5b312cd5f67646005312d2ebb2ef0d1bc584dcff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 5 Mar 2024 15:54:41 +0800 Subject: fix(eval): make has('pythonx') work properly (#27739) Problem: has('pythonx') always returns 1. Solution: Make it the same as has('python3'). --- test/functional/provider/python3_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/functional/provider/python3_spec.lua') diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua index 9bde57f777..80b3552e82 100644 --- a/test/functional/provider/python3_spec.lua +++ b/test/functional/provider/python3_spec.lua @@ -20,6 +20,12 @@ do matches(expected, pcall_err(command, 'py3 print("foo")')) matches(expected, pcall_err(command, 'py3file foo')) end) + it('feature test when Python 3 provider is missing', function() + eq(0, eval('has("python3")')) + eq(0, eval('has("python3_compiled")')) + eq(0, eval('has("python3_dynamic")')) + eq(0, eval('has("pythonx")')) + end) pending( string.format('Python 3 (or the pynvim module) is broken/missing (%s)', reason), function() end @@ -38,6 +44,7 @@ describe('python3 provider', function() eq(1, eval('has("python3")')) eq(1, eval('has("python3_compiled")')) eq(1, eval('has("python3_dynamic")')) + eq(1, eval('has("pythonx")')) eq(0, eval('has("python3_dynamic_")')) eq(0, eval('has("python3_")')) end) -- cgit