Allow warnings about trailing whitespace to be disabled for pycodestyle, and cover the flake8 code with tests

This commit is contained in:
w0rp 2017-11-28 10:12:49 +00:00
parent 0ab689db0a
commit a43ada93e4
3 changed files with 84 additions and 0 deletions

View file

@ -1,7 +1,9 @@
Before:
Save g:ale_warn_about_trailing_blank_lines
Save g:ale_warn_about_trailing_whitespace
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
runtime ale_linters/python/flake8.vim
@ -9,6 +11,7 @@ After:
Restore
unlet! b:ale_warn_about_trailing_blank_lines
unlet! b:ale_warn_about_trailing_whitespace
call ale#linter#Reset()
@ -150,6 +153,42 @@ Execute(The flake8 handler should handle names with spaces):
\ 'C:\something\with spaces.py:6:6: E111 indentation is not a multiple of four',
\ ])
Execute(Warnings about trailing whitespace should be reported by default):
AssertEqual
\ [
\ {
\ 'lnum': 6,
\ 'col': 1,
\ 'code': 'W291',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'who cares',
\ },
\ {
\ 'lnum': 6,
\ 'col': 1,
\ 'code': 'W293',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'who cares',
\ },
\ ],
\ ale_linters#python#flake8#Handle(bufnr(''), [
\ 'foo.py:6:1: W291 who cares',
\ 'foo.py:6:1: W293 who cares',
\ ])
Execute(Disabling trailing whitespace warnings should work):
let b:ale_warn_about_trailing_whitespace = 0
AssertEqual
\ [
\ ],
\ ale_linters#python#flake8#Handle(bufnr(''), [
\ 'foo.py:6:1: W291 who cares',
\ 'foo.py:6:1: W293 who cares',
\ ])
Execute(Warnings about trailing blank lines should be reported by default):
AssertEqual
\ [

View file

@ -1,7 +1,9 @@
Before:
Save g:ale_warn_about_trailing_blank_lines
Save g:ale_warn_about_trailing_whitespace
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
runtime ale_linters/python/pycodestyle.vim
@ -9,6 +11,7 @@ After:
Restore
unlet! b:ale_warn_about_trailing_blank_lines
unlet! b:ale_warn_about_trailing_whitespace
call ale#linter#Reset()
silent file something_else.py
@ -73,6 +76,42 @@ Execute(The pycodestyle handler should parse output):
\ 'example.py:544:21: W601 .has_key() is deprecated, use ''in''',
\ ])
Execute(Warnings about trailing whitespace should be reported by default):
AssertEqual
\ [
\ {
\ 'lnum': 6,
\ 'col': 1,
\ 'code': 'W291',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'who cares',
\ },
\ {
\ 'lnum': 6,
\ 'col': 1,
\ 'code': 'W293',
\ 'type': 'W',
\ 'sub_type': 'style',
\ 'text': 'who cares',
\ },
\ ],
\ ale_linters#python#pycodestyle#Handle(bufnr(''), [
\ 'foo.py:6:1: W291 who cares',
\ 'foo.py:6:1: W293 who cares',
\ ])
Execute(Disabling trailing whitespace warnings should work):
let b:ale_warn_about_trailing_whitespace = 0
AssertEqual
\ [
\ ],
\ ale_linters#python#pycodestyle#Handle(bufnr(''), [
\ 'foo.py:6:1: W291 who cares',
\ 'foo.py:6:1: W293 who cares',
\ ])
Execute(Warnings about trailing blank lines should be reported by default):
AssertEqual
\ [