]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_flakehell.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / linter / test_flakehell.vader
1 Before:
2   call ale#assert#SetUpLinterTest('python', 'flakehell')
3
4   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
5
6   GivenCommandOutput ['0.8.0']
7
8 After:
9   unlet! b:executable
10   unlet! b:bin_dir
11   call ale#assert#TearDownLinterTest()
12
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 -',
17   \]
18
19   " The version check should be cached.
20   GivenCommandOutput []
21   AssertLinter 'flakehell', [
22   \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
23   \]
24
25 Execute(The option for disabling changing directories should work):
26   let g:ale_python_flakehell_change_directory = 'off'
27
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 -',
33   \]
34
35   let g:ale_python_flakehell_change_directory = 0
36
37   AssertLinterCwd ['']
38   AssertLinter 'flakehell', [
39   \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
40   \]
41
42   " Invalid options should be considered the same as turning the setting off.
43   let g:ale_python_flakehell_change_directory = 'xxx'
44
45   AssertLinterCwd ['']
46   AssertLinter 'flakehell', [
47   \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
48   \]
49
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')
52
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 -',
58   \]
59
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')
63
64   AssertLinter 'flakehell', [
65   \ ale#Escape('flakehell') . ' --version',
66   \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
67   \]
68
69   let g:ale_python_flakehell_change_directory = 1
70
71   AssertLinter 'flakehell', [
72   \ ale#Escape('flakehell') . ' lint --format=default --stdin-display-name %s -',
73   \]
74
75 Execute(The flakehell command callback should let you set options):
76   let g:ale_python_flakehell_options = '--some-option'
77
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 -',
83   \]
84
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')
88
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')
94   \   . ' lint'
95   \   . ' --format=default'
96   \   . ' --stdin-display-name %s -',
97   \]
98
99 Execute(The flakehell callbacks should detect virtualenv directories):
100   call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
101
102   let b:executable = ale#path#Simplify(
103   \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/flakehell'
104   \)
105
106   AssertLinter b:executable, [
107   \ ale#Escape(b:executable) . ' --version',
108   \ ale#Escape(b:executable)
109   \   . ' lint'
110   \   . ' --format=default'
111   \   . ' --stdin-display-name %s -',
112   \]
113
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')
116
117   AssertEqual
118   \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_manifest'),
119   \ ale#python#FindProjectRoot(bufnr(''))
120
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')
123
124   AssertEqual
125   \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_setup'),
126   \ ale#python#FindProjectRoot(bufnr(''))
127
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')
130
131   AssertEqual
132   \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_pytest'),
133   \ ale#python#FindProjectRoot(bufnr(''))
134
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')
137
138   AssertEqual
139   \ ale#path#Simplify(g:dir . '/../test-files/python/namespace_package_tox'),
140   \ ale#python#FindProjectRoot(bufnr(''))
141
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')
144
145   AssertEqual
146   \ ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir'),
147   \ ale#python#FindProjectRoot(bufnr(''))
148
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')
152
153   let g:ale_python_flakehell_executable = 'python'
154   let g:ale_python_flakehell_options = '--some-option'
155
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 -'
160   \]
161
162   call ale#semver#ResetVersionCache()
163
164   " Leading spaces shouldn't matter
165   let g:ale_python_flakehell_options = '   --some-option'
166
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 -'
171   \]
172
173 Execute(Setting executable to 'pipenv' should append 'run flakehell'):
174   let g:ale_python_flakehell_executable = 'path/to/pipenv'
175
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 -'
180
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')
184
185   AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
186   AssertLinter 'pipenv',
187   \ ale#Escape('pipenv') . ' run flakehell lint --format=default --stdin-display-name %s -'
188
189 Execute(Setting executable to 'poetry' should append 'run flakehell'):
190   let g:ale_python_flakehell_executable = 'path/to/poetry'
191
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 -'
196
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')
200
201   AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
202   AssertLinter 'poetry',
203   \ ale#Escape('poetry') . ' run flakehell lint --format=default --stdin-display-name %s -'
204
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')
208
209   AssertLinter 'uv',
210   \ ale#Escape('uv') . ' run flakehell lint --format=default --stdin-display-name %s -'