summaryrefslogtreecommitdiff
path: root/test/handler/test_prospector_handler.vader
blob: 7962f6cddfba8eabfae64e9fdb197467c0f60d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
Before:
  Save g:ale_warn_about_trailing_whitespace

  let g:ale_warn_about_trailing_whitespace = 1

  runtime ale_linters/python/prospector.vim

After:
  Restore

  call ale#linter#Reset()

  silent file something_else.py

Execute(Basic prospector errors should be handle):
  AssertEqual
  \ [
  \   {
  \     'lnum': 20,
  \     'col': 1,
  \     'text': 'Trailing whitespace',
  \     'code': '(pylint) trailing-whitespace',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 1,
  \     'col': 1,
  \     'text': 'Missing module docstring',
  \     'code': '(pylint) missing-docstring',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 2,
  \     'col': 1,
  \     'text': 'Missing function docstring',
  \     'code': '(pylint) missing-docstring',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 3,
  \     'col': 5,
  \     'text': '''break'' not properly in loop',
  \     'code': '(pylint) not-in-loop',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 4,
  \     'col': 5,
  \     'text': 'Unreachable code',
  \     'code': '(pylint) unreachable',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 7,
  \     'col': 33,
  \     'text': 'No exception type(s) specified',
  \     'code': '(pylint) bare-except',
  \     'type': 'E',
  \   },
  \ ],
  \ ale_linters#python#prospector#Handle(bufnr(''), [
  \ '{',
  \ '  "messages": [',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "trailing-whitespace",',
  \ '      "message": "Trailing whitespace",',
  \ '      "location": {',
  \ '        "character": 0,',
  \ '        "line": 20',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "missing-docstring",',
  \ '      "message": "Missing module docstring",',
  \ '      "location": {',
  \ '        "character": 0,',
  \ '        "line": 1',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "missing-docstring",',
  \ '      "message": "Missing function docstring",',
  \ '      "location": {',
  \ '        "character": 0,',
  \ '        "line": 2',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "not-in-loop",',
  \ '      "message": "''break'' not properly in loop",',
  \ '      "location": {',
  \ '        "character": 4,',
  \ '        "line": 3',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "unreachable",',
  \ '      "message": "Unreachable code",',
  \ '      "location": {',
  \ '        "character": 4,',
  \ '        "line": 4',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "bare-except",',
  \ '      "message": "No exception type(s) specified",',
  \ '      "location": {',
  \ '        "character": 32,',
  \ '        "line": 7',
  \ '      }',
  \ '    }',
  \ '  ]',
  \ '}',
  \ ])

Execute(Ignoring trailing whitespace messages should work):
  let g:ale_warn_about_trailing_whitespace = 0

  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 1,
  \     'text': 'Missing module docstring',
  \     'code': '(pylint) missing-docstring',
  \     'type': 'E',
  \   },
  \ ],
  \ ale_linters#python#prospector#Handle(bufnr(''), [
  \ '{',
  \ '  "messages": [',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "trailing-whitespace",',
  \ '      "message": "Trailing whitespace",',
  \ '      "location": {',
  \ '        "character": 0,',
  \ '        "line": 4',
  \ '      }',
  \ '    },',
  \ '    {',
  \ '      "source": "pylint",',
  \ '      "code": "missing-docstring",',
  \ '      "message": "Missing module docstring",',
  \ '      "location": {',
  \ '        "character": 0,',
  \ '        "line": 1',
  \ '      }',
  \ '    }',
  \ '  ]',
  \ '}',
  \ ])