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', 'flake8')
4 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
6 GivenCommandOutput ['3.0.0']
11 call ale#assert#TearDownLinterTest()
13 Execute(The flake8 callbacks should return the correct default values):
14 AssertLinter 'flake8', [
15 \ ale#Escape('flake8') . ' --version',
16 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
19 " The version check should be cached.
21 AssertLinter 'flake8', [
22 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
25 " Try with older versions.
26 call ale#semver#ResetVersionCache()
27 GivenCommandOutput ['2.9.9']
28 AssertLinter 'flake8', [
29 \ ale#Escape('flake8') . ' --version',
30 \ ale#Escape('flake8') . ' --format=default -',
33 Execute(The option for disabling changing directories should work):
34 let g:ale_python_flake8_change_directory = 'off'
36 AssertLinterCwd ['', '']
37 call ale#semver#ResetVersionCache()
38 AssertLinter 'flake8', [
39 \ ale#Escape('flake8') . ' --version',
40 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
43 let g:ale_python_flake8_change_directory = 0
46 AssertLinter 'flake8', [
47 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
50 " Invalid options should be considered the same as turning the setting off.
51 let g:ale_python_flake8_change_directory = 'xxx'
54 AssertLinter 'flake8', [
55 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
58 Execute(The option for changing directory to project root should work):
59 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
61 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
62 call ale#semver#ResetVersionCache()
63 AssertLinter 'flake8', [
64 \ ale#Escape('flake8') . ' --version',
65 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
68 Execute(The option for changing directory to file dir should work):
69 let g:ale_python_flake8_change_directory = 'file'
70 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
72 AssertLinter 'flake8', [
73 \ ale#Escape('flake8') . ' --version',
74 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
77 let g:ale_python_flake8_change_directory = 1
79 AssertLinter 'flake8', [
80 \ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
83 Execute(The flake8 command callback should let you set options):
84 let g:ale_python_flake8_options = '--some-option'
86 GivenCommandOutput ['3.0.4']
87 AssertLinter 'flake8', [
88 \ ale#Escape('flake8') . ' --version',
89 \ ale#Escape('flake8') . ' --some-option'
90 \ . ' --format=default --stdin-display-name %s -',
93 call ale#semver#ResetVersionCache()
94 GivenCommandOutput ['2.9.9']
95 AssertLinter 'flake8', [
96 \ ale#Escape('flake8') . ' --version',
97 \ ale#Escape('flake8') . ' --some-option --format=default -',
100 Execute(You should be able to set a custom executable and it should be escaped):
101 call ale#test#SetFilename('../test-files/dummy')
103 let g:ale_python_flake8_executable = 'executable with spaces'
105 AssertLinterCwd ['%s:h', '%s:h']
106 call ale#semver#ResetVersionCache()
107 AssertLinter 'executable with spaces', [
108 \ ale#Escape('executable with spaces') . ' --version',
109 \ ale#Escape('executable with spaces')
110 \ . ' --format=default'
111 \ . ' --stdin-display-name %s -',
114 Execute(The flake8 callbacks should detect virtualenv directories):
115 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
117 let b:executable = ale#path#Simplify(
118 \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/flake8'
121 AssertLinter b:executable, [
122 \ ale#Escape(b:executable) . ' --version',
123 \ ale#Escape(b:executable)
124 \ . ' --format=default'
125 \ . ' --stdin-display-name %s -',
128 Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
129 call ale#test#SetFilename('../test-files/python/namespace_package_manifest/namespace/foo/bar.py')
132 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
133 \ ale#python#FindProjectRoot(bufnr(''))
135 Execute(The FindProjectRoot should detect the project root directory for namespace package via setup.cf):
136 call ale#test#SetFilename('../test-files/python/namespace_package_setup/namespace/foo/bar.py')
139 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
140 \ ale#python#FindProjectRoot(bufnr(''))
142 Execute(The FindProjectRoot should detect the project root directory for namespace package via pytest.ini):
143 call ale#test#SetFilename('../test-files/python/namespace_package_pytest/namespace/foo/bar.py')
146 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
147 \ ale#python#FindProjectRoot(bufnr(''))
149 Execute(The FindProjectRoot should detect the project root directory for namespace package via tox.ini):
150 call ale#test#SetFilename('../test-files/python/namespace_package_tox/namespace/foo/bar.py')
153 \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
154 \ ale#python#FindProjectRoot(bufnr(''))
156 Execute(The FindProjectRoot should detect the project root directory for non-namespace package):
157 call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
160 \ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
161 \ ale#python#FindProjectRoot(bufnr(''))
163 " Some users currently run flake8 this way, so we should support it.
164 Execute(Using `python -m flake8` should be supported for running flake8):
165 call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
167 let g:ale_python_flake8_executable = 'python'
168 let g:ale_python_flake8_options = '-m flake8 --some-option'
170 GivenCommandOutput ['2.9.9']
171 AssertLinter 'python', [
172 \ ale#Escape('python') . ' -m flake8 --version',
173 \ ale#Escape('python')
174 \ . ' -m flake8 --some-option --format=default -'
177 call ale#semver#ResetVersionCache()
179 " Leading spaces shouldn't matter
180 let g:ale_python_flake8_options = ' -m flake8 --some-option'
182 GivenCommandOutput ['2.9.9']
183 AssertLinter 'python', [
184 \ ale#Escape('python') . ' -m flake8 --version',
185 \ ale#Escape('python')
186 \ . ' -m flake8 --some-option --format=default -'
189 Execute(Setting executable to 'pipenv' should append 'run flake8'):
190 let g:ale_python_flake8_executable = 'path/to/pipenv'
192 " FIXME: pipenv should check the version with flake8.
193 GivenCommandOutput []
194 AssertLinter 'path/to/pipenv',
195 \ ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
197 Execute(Pipenv is detected when python_flake8_auto_pipenv is set):
198 let g:ale_python_flake8_auto_pipenv = 1
199 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
201 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
202 AssertLinter 'pipenv',
203 \ ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'
205 Execute(Setting executable to 'poetry' should append 'run flake8'):
206 let g:ale_python_flake8_executable = 'path/to/poetry'
208 " FIXME: poetry should check the version with flake8.
209 GivenCommandOutput []
210 AssertLinter 'path/to/poetry',
211 \ ale#Escape('path/to/poetry') . ' run flake8 --format=default -'
213 Execute(poetry is detected when python_flake8_auto_poetry is set):
214 let g:ale_python_flake8_auto_poetry = 1
215 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
217 AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
218 AssertLinter 'poetry',
219 \ ale#Escape('poetry') . ' run flake8 --format=default --stdin-display-name %s -'
221 Execute(uv is detected when python_flake8_auto_uv is set):
222 let g:ale_python_flake8_auto_uv = 1
223 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
226 \ ale#Escape('uv') . ' run flake8 --format=default --stdin-display-name %s -'