summaryrefslogtreecommitdiff
path: root/test/linter
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2023-02-08 09:11:31 +0000
committerw0rp <devw0rp@gmail.com>2023-02-08 09:11:31 +0000
commit4c162877e2943ac8f6b29bc79ccf313f8eb88ba6 (patch)
tree7f40105c0a914615ae3bd1bdfb607d1409222b9f /test/linter
parent6ff1f0b200f9d280b44b9fa59fde232bdb9fe32f (diff)
downloadale-4c162877e2943ac8f6b29bc79ccf313f8eb88ba6.zip
#2172 Auto PATH with ale_python_auto_virtualenv
Automatically set `PATH` for some Python linters that seem to need it when g:ale_python_auto_virtualenv or b:ale_python_auto_virtualenv is `1`.
Diffstat (limited to 'test/linter')
-rw-r--r--test/linter/test_jedils.vader47
-rw-r--r--test/linter/test_pylsp.vader14
-rw-r--r--test/linter/test_pyright.vader14
3 files changed, 75 insertions, 0 deletions
diff --git a/test/linter/test_jedils.vader b/test/linter/test_jedils.vader
new file mode 100644
index 00000000..0c2781bd
--- /dev/null
+++ b/test/linter/test_jedils.vader
@@ -0,0 +1,47 @@
+Before:
+ call ale#assert#SetUpLinterTest('python', 'jedils')
+ Save b:ale_python_auto_virtualenv
+
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+
+After:
+ unlet! b:bin_dir
+ unlet! b:venv_bin
+ unlet! b:sep
+ unlet! b:executable
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The jedi-language-server command callback should return default string):
+ call ale#test#SetFilename('./foo.py')
+
+ AssertLinter 'jedi-language-server', ale#Escape('jedi-language-server')
+
+Execute(The jedi-language-server executable should be configurable):
+ let g:ale_python_jedils_executable = '~/.local/bin/jedi-language-server'
+
+ AssertLinter '~/.local/bin/jedi-language-server' , ale#Escape('~/.local/bin/jedi-language-server')
+
+Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
+ let b:ale_python_auto_virtualenv = 1
+ call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
+
+ let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
+ let b:sep = has('win32') ? ';' : ':'
+ let b:executable = ale#path#Simplify(b:venv_bin . '/jedi-language-server')
+
+ AssertLinter b:executable, ale#Env('PATH', b:venv_bin . b:sep . $PATH)
+ \ . ale#Escape(b:executable)
+
+Execute(You should be able to override the jedi-language-server virtualenv lookup):
+ call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
+
+ let g:ale_python_jedils_use_global = 1
+
+ AssertLinter 'jedi-language-server', ale#Escape('jedi-language-server')
+
+Execute(Setting executable to 'pipenv' appends 'run jedi-language-server'):
+ let g:ale_python_jedils_executable = 'path/to/pipenv'
+ call ale#test#SetFilename('../test-files/dummy')
+
+ AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run jedi-language-server'
diff --git a/test/linter/test_pylsp.vader b/test/linter/test_pylsp.vader
index 34cc30c6..d1490978 100644
--- a/test/linter/test_pylsp.vader
+++ b/test/linter/test_pylsp.vader
@@ -1,10 +1,13 @@
Before:
call ale#assert#SetUpLinterTest('python', 'pylsp')
+ Save b:ale_python_auto_virtualenv
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
unlet! b:bin_dir
+ unlet! b:venv_bin
+ unlet! b:sep
unlet! b:executable
call ale#assert#TearDownLinterTest()
@@ -40,6 +43,17 @@ Execute(The pylsp executable should be run from the virtualenv path):
AssertEqual ale#Escape(b:executable),
\ ale_linters#python#pylsp#GetCommand(bufnr(''))
+Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
+ let b:ale_python_auto_virtualenv = 1
+ call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
+
+ let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
+ let b:sep = has('win32') ? ';' : ':'
+ let b:executable = ale#path#Simplify(b:venv_bin . '/pylsp')
+
+ AssertLinter b:executable, ale#Env('PATH', b:venv_bin . b:sep . $PATH)
+ \ . ale#Escape(b:executable)
+
Execute(You should be able to override the pylsp virtualenv lookup):
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
diff --git a/test/linter/test_pyright.vader b/test/linter/test_pyright.vader
index 303efa24..c81ab4b4 100644
--- a/test/linter/test_pyright.vader
+++ b/test/linter/test_pyright.vader
@@ -1,10 +1,13 @@
Before:
call ale#assert#SetUpLinterTest('python', 'pyright')
+ Save b:ale_python_auto_virtualenv
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
unlet! b:bin_dir
+ unlet! b:venv_bin
+ unlet! b:sep
unlet! b:executable
call ale#assert#TearDownLinterTest()
@@ -132,6 +135,17 @@ Execute(The pyright callbacks should detect virtualenv directories):
AssertLinter b:executable, ale#Escape(b:executable) . ' --stdio'
+Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
+ let b:ale_python_auto_virtualenv = 1
+ call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
+
+ let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
+ let b:sep = has('win32') ? ';' : ':'
+ let b:executable = ale#path#Simplify(b:venv_bin . '/pyright-langserver')
+
+ AssertLinter b:executable, ale#Env('PATH', b:venv_bin . b:sep . $PATH)
+ \ . ale#Escape(b:executable) . ' --stdio'
+
Execute(Setting executable to 'pipenv' should append 'run pyright'):
call ale#test#SetFilename('../test-files')