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', 'flakehell')
4 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
6 GivenCommandOutput ['0.8.0']
11 call ale#assert#TearDownLinterTest()
13 Execute(The flakehell callbacks should return the correct default values):
14 AssertLinter 'flakehell', [
15 \ ale#Escape('flakehell') . ' --version',
16 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
19 " The version check should be cached.
21 AssertLinter 'flakehell', [
22 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
25 Execute(The option for disabling changing directories should work):
26 let g:ale_python_flakehell_change_directory = 'off'
28 AssertLinterCwd ['', '']
29 call ale#semver#ResetVersionCache()
30 AssertLinter 'flakehell', [
31 \ ale#Escape('flakehell') . ' --version',
32 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
35 let g:ale_python_flakehell_change_directory = 0
38 AssertLinter 'flakehell', [
39 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
42 " Invalid options should be considered the same as turning the setting off.
43 let g:ale_python_flakehell_change_directory = 'xxx'
46 AssertLinter 'flakehell', [
47 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
50 Execute(The option for changing directory to project root should work):
51 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
53 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
54 call ale#semver#ResetVersionCache()
55 AssertLinter 'flakehell', [
56 \ ale#Escape('flakehell') . ' --version',
57 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
60 Execute(The option for changing directory to file dir should work):
61 let g:ale_python_flakehell_change_directory = 'file'
62 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
64 AssertLinter 'flakehell', [
65 \ ale#Escape('flakehell') . ' --version',
66 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
69 let g:ale_python_flakehell_change_directory = 1
71 AssertLinter 'flakehell', [
72 \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
75 Execute(The flakehell command callback should let you set options):
76 let g:ale_python_flakehell_options = '--some-option'
78 GivenCommandOutput ['0.8.0']
79 AssertLinter 'flakehell', [
80 \ ale#Escape('flakehell') . ' --version',
81 \ ale#Escape('flakehell') . ' lint --some-option'
82 \ . ' --format=default --stdin-display-name %s -',
85 Execute(You should be able to set a custom executable and it should be escaped):
86 let g:ale_python_flakehell_executable = 'executable with spaces'
87 call ale#test#SetFilename('../test-files/dummy')
89 AssertLinterCwd ['%s:h', '%s:h']
90 call ale#semver#ResetVersionCache()
91 AssertLinter 'executable with spaces', [
92 \ ale#Escape('executable with spaces') . ' --version',
93 \ ale#Escape('executable with spaces')
95 \ . ' --format=default'
96 \ . ' --stdin-display-name %s -',
99 Execute(The flakehell callbacks should detect virtualenv directories):
100 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
102 let b:executable = ale#path#Simplify(
103 \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/flakehell'
106 AssertLinter b:executable, [
107 \ ale#Escape(b:executable) . ' --version',
108 \ ale#Escape(b:executable)
110 \ . ' --format=default'
111 \ . ' --stdin-display-name %s -',
114 Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
115 call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
118 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
119 \ ale#python#FindProjectRoot(bufnr(''))
121 Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
122 call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
125 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
126 \ ale#python#FindProjectRoot(bufnr(''))
128 Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
129 call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
132 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
133 \ ale#python#FindProjectRoot(bufnr(''))
135 Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
136 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
139 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
140 \ ale#python#FindProjectRoot(bufnr(''))
142 Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
143 call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
146 \ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
147 \ ale#python#FindProjectRoot(bufnr(''))
149 " Some users currently run flakehell this way, so we should support it.
150 Execute(Using `python -m flakehell` should be supported for running flakehell):
151 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
153 let g:ale_python_flakehell_executable = 'python'
154 let g:ale_python_flakehell_options = '--some-option'
156 AssertLinter 'python', [
157 \ ale#Escape('python') . ' -m flakehell --version',
158 \ ale#Escape('python')
159 \ . ' -m flakehell lint --some-option --format=default --stdin-display-name %s -'
162 call ale#semver#ResetVersionCache()
164 " Leading spaces shouldn't matter
165 let g:ale_python_flakehell_options = ' --some-option'
167 AssertLinter 'python', [
168 \ ale#Escape('python') . ' -m flakehell --version',
169 \ ale#Escape('python')
170 \ . ' -m flakehell lint --some-option --format=default --stdin-display-name %s -'
173 Execute(Setting executable to 'pipenv' should append 'run flakehell'):
174 let g:ale_python_flakehell_executable = 'path/to/pipenv'
176 " FIXME: pipenv should check the version with flakehell.
177 GivenCommandOutput []
178 AssertLinter 'path/to/pipenv',
179 \ ale#Escape('path/to/pipenv') . ' run flakehell lint --format=default -'
181 Execute(Pipenv is detected when python_flakehell_auto_pipenv is set):
182 let g:ale_python_flakehell_auto_pipenv = 1
183 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
185 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
186 AssertLinter 'pipenv',
187 \ ale#Escape('pipenv') . ' run flakehell lint --format=default --stdin-display-name %s -'
189 Execute(Setting executable to 'poetry' should append 'run flakehell'):
190 let g:ale_python_flakehell_executable = 'path/to/poetry'
192 " FIXME: poetry should check the version with flakehell.
193 GivenCommandOutput []
194 AssertLinter 'path/to/poetry',
195 \ ale#Escape('path/to/poetry') . ' run flakehell lint --format=default -'
197 Execute(poetry is detected when python_flakehell_auto_poetry is set):
198 let g:ale_python_flakehell_auto_poetry = 1
199 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
201 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
202 AssertLinter 'poetry',
203 \ ale#Escape('poetry') . ' run flakehell lint --format=default --stdin-display-name %s -'
205 Execute(uv is detected when python_flakehell_auto_uv is set):
206 let g:ale_python_flakehell_auto_uv = 1
207 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
210 \ ale#Escape('uv') . ' run flakehell lint --format=default --stdin-display-name %s -'