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', 'pyright')
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 command callback should return the correct default string):
17 call ale#test#SetFilename('./foo.py')
20 \ 'pyright-langserver',
21 \ ale#Escape('pyright-langserver') . ' --stdio'
23 Execute(The executable should be configurable):
24 let g:ale_python_pyright_executable = '/bin/foo-bar'
28 \ ale#Escape('/bin/foo-bar') . ' --stdio'
30 Execute(The default configuration should be mostly empty):
31 " The default configuration needs to have at least one key in it,
32 " or the server won't start up properly.
33 AssertLSPConfig {'python': {}}
35 let b:ale_python_pyright_config = {}
37 AssertLSPConfig {'python': {}}
39 Execute(The cwd and project root should be detected correctly):
40 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
42 AssertLinterCwd ale#test#GetFilename('../test-files/python/with_virtualenv/subdir')
43 AssertLSPProject ale#test#GetFilename('../test-files/python/with_virtualenv/subdir')
45 Execute(virtualenv paths should be set in configuration by default):
46 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
50 \ 'pythonPath': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/python'),
51 \ 'venvPath': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env'),
55 Execute(The pythonPath should be set based on whatever the override for the venvPath is set to):
56 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
58 " This overrides the default detection of the path.
59 let b:ale_python_pyright_config = {
61 \ 'venvPath': '/foo/bar',
67 \ 'pythonPath': ale#path#Simplify('/foo/bar/' . b:bin_dir . '/python'),
68 \ 'venvPath': '/foo/bar',
72 Execute(You should be able to override pythonPath when venvPath is detected):
73 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
75 " This overrides the default detection of the path.
76 let b:ale_python_pyright_config = {
78 \ 'pythonPath': '/bin/python',
84 \ 'pythonPath': '/bin/python',
85 \ 'venvPath': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env'),
89 Execute(You should be able to override both pythonPath and venvPath):
90 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
92 " This overrides the default detection of the path.
93 let b:ale_python_pyright_config = {
95 \ 'pythonPath': '/bin/python',
96 \ 'venvPath': '/other/dir',
102 \ 'pythonPath': '/bin/python',
103 \ 'venvPath': '/other/dir',
107 Execute(You should be able to define other settings):
108 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
110 let b:ale_python_pyright_config = {
112 \ 'analysis': {'logLevel': 'warning'},
115 \ 'disableLanguageServices': v:true,
121 \ 'analysis': {'logLevel': 'warning'},
122 \ 'pythonPath': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/python'),
123 \ 'venvPath': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env'),
126 \ 'disableLanguageServices': v:true,
130 Execute(The pyright callbacks should detect virtualenv directories):
131 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
133 let b:executable = ale#path#Simplify(
134 \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pyright-langserver'
137 AssertLinter b:executable, ale#Escape(b:executable) . ' --stdio'
139 Execute(virtualenv vars should be used when ale_python_auto_virtualenv = 1):
140 let b:ale_python_auto_virtualenv = 1
141 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
143 let b:venv_bin = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir)
144 let b:sep = has('win32') ? ';' : ':'
145 let b:executable = ale#path#Simplify(b:venv_bin . '/pyright-langserver')
147 AssertLinter b:executable, ale#python#AutoVirtualenvEnvString(bufnr(''))
148 \ . ale#Escape(b:executable) . ' --stdio'
149 Assert !empty(ale#python#AutoVirtualenvEnvString(bufnr('')))
151 Execute(Setting executable to 'pipenv' should append 'run pyright-langserver'):
152 call ale#test#SetFilename('../test-files')
154 let g:ale_python_pyright_executable = 'path/to/pipenv'
156 GivenCommandOutput []
157 AssertLinter 'path/to/pipenv',
158 \ ale#Escape('path/to/pipenv') . ' run pyright-langserver --stdio'
160 Execute(Pipenv is detected when python_pyright_auto_pipenv is set):
161 let g:ale_python_pyright_auto_pipenv = 1
162 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
164 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
165 AssertLinter 'pipenv',
166 \ ale#Escape('pipenv') . ' run pyright-langserver --stdio'
168 Execute(Setting executable to 'poetry' should append 'run pyright-langserver'):
169 let g:ale_python_pyright_executable = 'path/to/poetry'
171 GivenCommandOutput []
172 AssertLinter 'path/to/poetry',
173 \ ale#Escape('path/to/poetry') . ' run pyright-langserver --stdio'
175 Execute(poetry is detected when python_pyright_auto_poetry is set):
176 let g:ale_python_pyright_auto_poetry = 1
177 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
179 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
180 AssertLinter 'poetry',
181 \ ale#Escape('poetry') . ' run pyright-langserver --stdio'
183 Execute(uv is detected when python_pyright_auto_uv is set):
184 let g:ale_python_pyright_auto_uv = 1
185 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
188 \ ale#Escape('uv') . ' run pyright-langserver --stdio'