Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pytest.vim104 linesDownload Raw Back to compiler
1" Vim compiler file2" Compiler:     Pytest (Python testing framework)3" Maintainer:   @Konfekt and @mgedmin4" Last Change:  2024 Nov 285 6if exists("current_compiler") | finish | endif7let current_compiler = "pytest"8 9let s:cpo_save = &cpo10set cpo&vim11 12" CompilerSet makeprg=pytest13if has('unix')14  execute $'CompilerSet makeprg=/usr/bin/env\ PYTHONWARNINGS=ignore\ pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'15elseif has('win32')16  execute $'CompilerSet makeprg=set\ PYTHONWARNINGS=ignore\ &&\ pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'17else18  CompilerSet makeprg=pytest\ --tb=short\ --quiet19  execute $'CompilerSet makeprg=pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'20endif21 22" Pytest syntax errors                                          {{{223 24" Reset error format so that sourcing .vimrc again and again doesn't grow it25" without bounds26setlocal errorformat&27 28" For the record, the default errorformat is this:29"30"   %*[^"]"%f"%*\D%l: %m31"   "%f"%*\D%l: %m32"   %-G%f:%l: (Each undeclared identifier is reported only once33"   %-G%f:%l: for each function it appears in.)34"   %-GIn file included from %f:%l:%c:35"   %-GIn file included from %f:%l:%c\,36"   %-GIn file included from %f:%l:%c37"   %-GIn file included from %f:%l38"   %-G%*[ ]from %f:%l:%c39"   %-G%*[ ]from %f:%l:40"   %-G%*[ ]from %f:%l\,41"   %-G%*[ ]from %f:%l42"   %f:%l:%c:%m43"   %f(%l):%m44"   %f:%l:%m45"   "%f"\, line %l%*\D%c%*[^ ] %m46"   %D%*\a[%*\d]: Entering directory %*[`']%f'47"   %X%*\a[%*\d]: Leaving directory %*[`']%f'48"   %D%*\a: Entering directory %*[`']%f'49"   %X%*\a: Leaving directory %*[`']%f'50"   %DMaking %*\a in %f51"   %f|%l| %m52"53" and sometimes it misfires, so let's fix it up a bit54" (TBH I don't even know what compiler produces filename(lineno) so why even55" have it?)56setlocal errorformat-=%f(%l):%m57 58" Sometimes Vim gets confused about ISO-8601 timestamps and thinks they're59" filenames; this is a big hammer that ignores anything filename-like on lines60" that start with at least two spaces, possibly preceded by a number and61" optional punctuation62setlocal errorformat^=%+G%\\d%#%.%\\=\ \ %.%#63 64" Similar, but when the entire line starts with a date65setlocal errorformat^=%+G\\d\\d\\d\\d-\\d\\d-\\d\\d\ \\d\\d:\\d\\d%.%#66 67" make: *** [Makefile:14: target] Error 168setlocal errorformat^=%+Gmake:\ ***\ %.%#69 70" FAILED tests.py::test_with_params[YYYY-MM-DD:HH:MM:SS] - Exception: bla bla71setlocal errorformat^=%+GFAILED\ %.%#72 73" AssertionError: assert ...YYYY-MM-DD:HH:MM:SS...74setlocal errorformat^=%+GAssertionError:\ %.%#75 76" --- /path/to/file:before  YYYY-MM-DD HH:MM:SS.ssssss77setlocal errorformat^=---%f:%m78 79" +++ /path/to/file:before  YYYY-MM-DD HH:MM:SS.ssssss80setlocal errorformat^=+++%f:%m81 82" Sometimes pytest prepends an 'E' marker at the beginning of a traceback line83setlocal errorformat+=E\ %#File\ \"%f\"\\,\ line\ %l%.%#84 85" Python tracebacks (unittest + doctest output)                 {{{286 87" This collapses the entire traceback into just the last file+lineno,88" which is convenient when you want to jump to the line that failed (and not89" the top-level entry point), but it makes it impossible to see the full90" traceback, which sucks.91""setlocal errorformat+=92""            \File\ \"%f\"\\,\ line\ %l%.%#,93""            \%C\ %.%#,94""            \%-A\ \ File\ \"unittest%.py\"\\,\ line\ %.%#,95""            \%-A\ \ File\ \"%f\"\\,\ line\ 0%.%#,96""            \%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,97""            \%Z%[%^\ ]%\\@=%m98setlocal errorformat+=File\ \"%f\"\\,\ line\ %l\\,%#%m99 100exe 'CompilerSet errorformat='..escape(&l:errorformat, ' \|"')101 102let &cpo = s:cpo_save103unlet s:cpo_save104 
codekingpro/portable-devtools · Team Ai