All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 call ale#assert#SetUpLinterTest('python', 'pylsp')
3 Save b:ale_python_auto_virtualenv
5 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
13 call ale#test#SetFilename('..')
14 call ale#assert#TearDownLinterTest()
16 Execute(The default pylsp command should be correct):
17 call ale#test#SetFilename('./foo.py')
19 AssertLinter 'pylsp', ale#Escape('pylsp')
21 Execute(The pylsp command and executable should be configurable):
22 let g:ale_python_pylsp_executable = '~/.local/bin/pylsp'
23 let g:ale_python_pylsp_options = '--some-option'
25 AssertLinter '~/.local/bin/pylsp' , ale#Escape('~/.local/bin/pylsp')
28 Execute(The cwd and project root should be detected correctly):
29 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
31 AssertLinterCwd ale#test#GetFilename('../test-files/python/with_virtualenv/subdir')
32 AssertLSPProject ale#test#GetFilename('../test-files/python/with_virtualenv/subdir')
34 Execute(The pylsp executable should be run from the virtualenv path):
35 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
37 let b:executable = ale#path#Simplify(
38 \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pylsp'
41 AssertEqual ale#Escape(b:executable),
42 \ ale_linters#python#pylsp#GetCommand(bufnr(''))
44 Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
45 let b:ale_python_auto_virtualenv = 1
46 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
48 let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
49 let b:sep = has('win32') ? ';' : ':'
50 let b:executable = ale#path#Simplify(b:venv_bin . '/pylsp')
52 AssertLinter b:executable, ale#python#AutoVirtualenvEnvString(bufnr(''))
53 \ . ale#Escape(b:executable)
54 Assert !empty(ale#python#AutoVirtualenvEnvString(bufnr('')))
56 Execute(You should be able to override the pylsp virtualenv lookup):
57 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
59 let g:ale_python_pylsp_use_global = 1
61 AssertLinter 'pylsp', ale#Escape('pylsp')
63 Execute(Setting executable to 'pipenv' appends 'run pylsp'):
64 let g:ale_python_pylsp_executable = 'path/to/pipenv'
65 call ale#test#SetFilename('../test-files/dummy')
67 AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run pylsp'
69 Execute(Pipenv is detected when python_pylsp_auto_pipenv is set):
70 let g:ale_python_pylsp_auto_pipenv = 1
71 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
73 AssertLinter 'pipenv',
74 \ ale#Escape('pipenv') . ' run pylsp'
76 Execute(Setting executable to 'poetry' appends 'run pylsp'):
77 let g:ale_python_pylsp_executable = 'path/to/poetry'
79 AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run pylsp'
81 Execute(poetry is detected when python_pylsp_auto_poetry is set):
82 let g:ale_python_pylsp_auto_poetry = 1
83 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
85 AssertLinter 'poetry',
86 \ ale#Escape('poetry') . ' run pylsp'
88 Execute(uv is detected when python_pylsp_auto_uv is set):
89 let g:ale_python_pylsp_auto_uv = 1
90 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
93 \ ale#Escape('uv') . ' run pylsp'
95 Execute(Should accept configuration settings):
97 let b:ale_python_pylsp_config = {'pylsp': {'plugins': {'preload': {'enabled': v:false}}}}
98 AssertLSPConfig {'pylsp': {'plugins': {'preload': {'enabled': v:false}}}}