]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/handler/test_pylama_handler.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 / handler / test_pylama_handler.vader
1 Before:
2   Save g:ale_warn_about_trailing_whitespace
3
4   let g:ale_warn_about_trailing_whitespace = 1
5
6   runtime ale_linters/python/pylama.vim
7
8 After:
9   Restore
10
11   call ale#linter#Reset()
12
13   silent file something_else.py
14
15 Execute(The pylama handler should handle no messages with version older than 8.1.4):
16   AssertEqual [], ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [])
17
18 Execute(The pylama handler should handle no messages with version newer or equal than 8.1.4):
19   AssertEqual [], ale_linters#python#pylama#Handle(bufnr(''), [8, 2, 0], [])
20
21 Execute(The pylama handler should handle basic warnings and syntax errors with version older than 8.1.4):
22   AssertEqual
23   \ [
24   \   {
25   \     'lnum': 8,
26   \     'col': 1,
27   \     'code': 'W0611',
28   \     'type': 'W',
29   \     'sub_type': '',
30   \     'text': '''foo'' imported but unused [pyflakes]',
31   \   },
32   \   {
33   \     'lnum': 8,
34   \     'col': 0,
35   \     'code': 'E0401',
36   \     'type': 'E',
37   \     'sub_type': '',
38   \     'text': 'Unable to import ''foo'' [pylint]',
39   \   },
40   \   {
41   \     'lnum': 10,
42   \     'col': 1,
43   \     'code': 'E302',
44   \     'type': 'E',
45   \     'sub_type': '',
46   \     'text': 'expected 2 blank lines, found 1 [pycodestyle]',
47   \   },
48   \   {
49   \     'lnum': 11,
50   \     'col': 1,
51   \     'code': 'D401',
52   \     'type': 'W',
53   \     'sub_type': 'style',
54   \     'text': 'First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
55   \   },
56   \   {
57   \     'lnum': 15,
58   \     'col': 81,
59   \     'code': 'E501',
60   \     'type': 'E',
61   \     'sub_type': '',
62   \     'text': 'line too long (96 > 80 characters) [pycodestyle]',
63   \   },
64   \   {
65   \     'lnum': 16,
66   \     'col': 1,
67   \     'code': 'D203',
68   \     'type': 'W',
69   \     'sub_type': 'style',
70   \     'text': '1 blank line required before class docstring (found 0) [pydocstyle]',
71   \   },
72   \   {
73   \     'lnum': 18,
74   \     'col': 1,
75   \     'code': 'D107',
76   \     'type': 'W',
77   \     'sub_type': 'style',
78   \     'text': 'Missing docstring in __init__ [pydocstyle]',
79   \   },
80   \   {
81   \     'lnum': 20,
82   \     'col': 0,
83   \     'code': 'C4001',
84   \     'type': 'W',
85   \     'sub_type': 'style',
86   \     'text': 'Invalid string quote ", should be '' [pylint]',
87   \   },
88   \ ],
89   \ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
90   \   'No config file found, using default configuration',
91   \   'index.py:8:1: W0611 ''foo'' imported but unused [pyflakes]',
92   \   'index.py:8:0: E0401 Unable to import ''foo'' [pylint]',
93   \   'index.py:10:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
94   \   'index.py:11:1: D401 First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
95   \   'index.py:15:81: E501 line too long (96 > 80 characters) [pycodestyle]',
96   \   'index.py:16:1: D203 1 blank line required before class docstring (found 0) [pydocstyle]',
97   \   'index.py:18:1: D107 Missing docstring in __init__ [pydocstyle]',
98   \   'index.py:20:0: C4001 Invalid string quote ", should be '' [pylint]',
99   \ ])
100
101 Execute(The pylama handler should handle basic warnings and syntax errors with version newer than 8.1.4):
102   AssertEqual
103   \ [
104   \   {
105   \     'lnum': 8,
106   \     'col': 1,
107   \     'code': 'W0611',
108   \     'type': 'W',
109   \     'sub_type': '',
110   \     'text': '''foo'' imported but unused [pyflakes]',
111   \   },
112   \   {
113   \     'lnum': 8,
114   \     'col': 0,
115   \     'code': 'E0401',
116   \     'type': 'E',
117   \     'sub_type': '',
118   \     'text': 'Unable to import ''foo'' [pylint]',
119   \   },
120   \   {
121   \     'lnum': 10,
122   \     'col': 1,
123   \     'code': 'E302',
124   \     'type': 'E',
125   \     'sub_type': '',
126   \     'text': 'expected 2 blank lines, found 1 [pycodestyle]',
127   \   },
128   \   {
129   \     'lnum': 11,
130   \     'col': 1,
131   \     'code': 'D401',
132   \     'type': 'W',
133   \     'sub_type': 'style',
134   \     'text': 'First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
135   \   },
136   \   {
137   \     'lnum': 15,
138   \     'col': 81,
139   \     'code': 'E501',
140   \     'type': 'E',
141   \     'sub_type': '',
142   \     'text': 'line too long (96 > 80 characters) [pycodestyle]',
143   \   },
144   \   {
145   \     'lnum': 16,
146   \     'col': 1,
147   \     'code': 'D203',
148   \     'type': 'W',
149   \     'sub_type': 'style',
150   \     'text': '1 blank line required before class docstring (found 0) [pydocstyle]',
151   \   },
152   \   {
153   \     'lnum': 18,
154   \     'col': 1,
155   \     'code': 'D107',
156   \     'type': 'W',
157   \     'sub_type': 'style',
158   \     'text': 'Missing docstring in __init__ [pydocstyle]',
159   \   },
160   \   {
161   \     'lnum': 20,
162   \     'col': 0,
163   \     'code': 'C4001',
164   \     'type': 'W',
165   \     'sub_type': 'style',
166   \     'text': 'Invalid string quote ", should be '' [pylint]',
167   \   },
168   \ ],
169   \ ale_linters#python#pylama#Handle(bufnr(''), [8, 2, 0], [
170   \ '[{"source":"pyflakes","col":1,"lnum":8,"etype":"W","message":"''foo'' imported but unused","filename":"index.py","number":"W0611"},{"source":"pylint","col":0,"lnum":8,"etype":"E","message":"Unable to import ''foo''","filename":"index.py","number":"E0401"},{"source":"pycodestyle","col":1,"lnum":10,"etype":"E","message":"expected 2 blank lines, found 1","filename":"index.py","number":"E302"},{"source":"pydocstyle","col":1,"lnum":11,"etype":"D","message":"First line should be in imperative mood (''Get'', not ''Gets'')","filename":"index.py","number":"D401"},{"source":"pycodestyle","col":81,"lnum":15,"etype":"E","message":"line too long (96 > 80 characters)","filename":"index.py","number":"E501"},{"source":"pydocstyle","col":1,"lnum":16,"etype":"D","message":"1 blank line required before class docstring (found 0)","filename":"index.py","number":"D203"},{"source":"pydocstyle","col":1,"lnum":18,"etype":"D","message":"Missing docstring in __init__","filename":"index.py","number":"D107"},{"source":"pylint","col":0,"lnum":20,"etype":"C","message":"Invalid string quote \", should be ''","filename":"index.py","number":"C4001"}]',
171   \ ])
172
173 Execute(The pylama handler should handle tracebacks with parsable messages with version older than 8.1.4):
174   AssertEqual
175   \ [
176   \   {
177   \     'lnum': 1,
178   \     'text': 'ParseError: Cannot parse file. (See :ALEDetail)',
179   \     'detail': join([
180   \       'Traceback (most recent call last):',
181   \       '  File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
182   \       '    path, code=code, ignore=ignore, select=select, params=lparams)',
183   \       '  File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
184   \       '    } for e in PyDocChecker().check_source(*check_source_args)]',
185   \       '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
186   \       '    module = parse(StringIO(source), filename)',
187   \       '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
188   \       '    return self.parse(*args, **kwargs)',
189   \       '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
190   \       '    six.raise_from(ParseError(), error)',
191   \       '  File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
192   \       '    raise value',
193   \       'ParseError: Cannot parse file.',
194   \     ], "\n"),
195   \   },
196   \   {
197   \     'lnum': 11,
198   \     'col': 1,
199   \     'code': 'E302',
200   \     'type': 'E',
201   \     'sub_type': '',
202   \     'text': 'expected 2 blank lines, found 1 [pycodestyle]',
203   \   },
204   \   {
205   \     'lnum': 16,
206   \     'col': 81,
207   \     'code': 'E501',
208   \     'type': 'E',
209   \     'sub_type': '',
210   \     'text': 'line too long (96 > 80 characters) [pycodestyle]',
211   \   },
212   \ ],
213   \ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
214   \   'Traceback (most recent call last):',
215   \   '  File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
216   \   '    path, code=code, ignore=ignore, select=select, params=lparams)',
217   \   '  File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
218   \   '    } for e in PyDocChecker().check_source(*check_source_args)]',
219   \   '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
220   \   '    module = parse(StringIO(source), filename)',
221   \   '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
222   \   '    return self.parse(*args, **kwargs)',
223   \   '  File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
224   \   '    six.raise_from(ParseError(), error)',
225   \   '  File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
226   \   '    raise value',
227   \   'ParseError: Cannot parse file.',
228   \   '',
229   \   'index.py:11:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
230   \   'index.py:16:81: E501 line too long (96 > 80 characters) [pycodestyle]',
231   \ ])
232
233 " Note: This is probably a bug, since all pylama plugins produce codes, but
234 " should be handled for compatibility.
235 " Note: The pylama isort plugin is distributed in the isort package.
236 Execute(The pylama handler should handle messages without codes with version older than 8.1.4):
237   AssertEqual
238   \ [
239   \   {
240   \     'lnum': 0,
241   \     'col': 0,
242   \     'code': '',
243   \     'type': 'W',
244   \     'sub_type': '',
245   \     'text': 'Incorrectly sorted imports. [isort]'
246   \   },
247   \ ],
248   \ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
249   \   'index.py:0:0: Incorrectly sorted imports. [isort]',
250   \ ])
251
252 " Note: This is a pylama bug, but should be handled for compatibility.
253 " See https://github.com/klen/pylama/pull/146
254 Execute(The pylama handler should handle message codes followed by a colon with version older than 8.1.4):
255   AssertEqual
256   \ [
257   \   {
258   \     'lnum': 31,
259   \     'col': 1,
260   \     'code': 'E800',
261   \     'type': 'E',
262   \     'sub_type': '',
263   \     'text': 'Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
264   \   },
265   \ ],
266   \ ale_linters#python#pylama#Handle(bufnr(''), [8, 0, 5], [
267   \   'index.py:31:1: E800: Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
268   \ ])