test_pydocstyle_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/pydocstyle.vim 7 8 After: 9 Restore 10 11 call ale#linter#Reset() 12 13 silent file something_else.py 14 15 " File sample.py 16 " # sample.py file 17 " 18 " def main(): 19 " """ 20 " This is a multi-line description that should produce multiple errors to be 21 " tested by the handler 22 " """ 23 " return False 24 " 25 " 26 " if __name__ == '__main__': 27 " main() 28 " 29 " The command to generate the handler input is: 30 " 31 " $ python -m pydocstyle --verbose --source --explain sample.py 32 " [...] 33 " $ 34 35 Execute(Basic pydocstyle warnings should be handled): 36 AssertEqual 37 \ [ 38 \ { 39 \ 'lnum': 1, 40 \ 'col': 1, 41 \ 'text': 'Missing docstring in public module', 42 \ 'code': 'D100', 43 \ 'type': 'W', 44 \ }, 45 \ { 46 \ 'lnum': 4, 47 \ 'col': 1, 48 \ 'text': '1 blank line required between summary line and description (found 0)', 49 \ 'code': 'D205', 50 \ 'type': 'W', 51 \ }, 52 \ { 53 \ 'lnum': 4, 54 \ 'col': 1, 55 \ 'text': 'First line should end with a period (not ''e'')', 56 \ 'code': 'D400', 57 \ 'type': 'W', 58 \ }, 59 \ { 60 \ 'lnum': 4, 61 \ 'col': 1, 62 \ 'text': 'First line should be in imperative mood; try rephrasing (found ''This'')', 63 \ 'code': 'D401', 64 \ 'type': 'W', 65 \ }, 66 \ ], 67 \ ale_linters#python#pydocstyle#Handle(bufnr(''), [ 68 \ 'Checking file ' . fnamemodify(bufname(bufnr('')), ':p') . '.', 69 \ './mydir/myfile.py:1 at module level:', 70 \ ' D100: Missing docstring in public module', 71 \ '', 72 \ ' All modules should normally have docstrings. [...] all functions and', 73 \ ' classes exported by a module should also have docstrings. Public', 74 \ ' methods (including the __init__ constructor) should also have', 75 \ ' docstrings.', 76 \ ' Note: Public (exported) definitions are either those with names listed', 77 \ ' in __all__ variable (if present), or those that do not start', 78 \ ' with a single underscore.', 79 \ '', 80 \ ' 1: # 2: 3: s 4: a 5: m 6: p 7: l ...', 81 \ '', 82 \ '', 83 \ 'C:\mydir\myfile.py:4 in public function `main`:', 84 \ ' D205: 1 blank line required between summary line and description (found 0)', 85 \ '', 86 \ ' Multi-line docstrings consist of a summary line just like a one-line', 87 \ ' docstring, followed by a blank line, followed by a more elaborate', 88 \ ' description. The summary line may be used by automatic indexing tools;', 89 \ ' it is important that it fits on one line and is separated from the', 90 \ ' rest of the docstring by a blank line.', 91 \ '', 92 \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', 93 \ '', 94 \ '', 95 \ 'myfile.py:4 in public function `main`:', 96 \ ' D400: First line should end with a period (not ''e'')', 97 \ '', 98 \ ' The [first line of a] docstring is a phrase ending in a period.', 99 \ '', 100 \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', 101 \ '', 102 \ '', 103 \ ale#Escape(fnamemodify(bufname(bufnr('')), ':t')) . ':4 in public function `main`:', 104 \ ' D401: First line should be in imperative mood; try rephrasing (found ''This'')', 105 \ '', 106 \ ' [Docstring] prescribes the function or method''s effect as a command:', 107 \ ' ("Do this", "Return that"), not as a description; e.g. don''t write', 108 \ ' "Returns the pathname ...".', 109 \ '', 110 \ ' 3: d 4: e 5: f 6: 7: m 8: a 9: i ...', 111 \ ]) 112 113 Execute(Handler should handle empty output): 114 AssertEqual 115 \ [], 116 \ ale_linters#python#pydocstyle#Handle(bufnr(''), [])