mirror of
https://github.com/dense-analysis/ale.git
synced 2026-03-02 21:39:01 +08:00
wip
This commit is contained in:
37
test/handler/test_ty_handler.vader
Normal file
37
test/handler/test_ty_handler.vader
Normal file
@@ -0,0 +1,37 @@
|
||||
Before:
|
||||
runtime! ale_linters/python/ty.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(We should handle basic output from ty correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 2,
|
||||
\ 'end_lnum': 3,
|
||||
\ 'end_col': 10,
|
||||
\ 'code': 'TY001',
|
||||
\ 'text': 'Type check failed',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 6,
|
||||
\ 'col': 4,
|
||||
\ 'end_lnum': 6,
|
||||
\ 'end_col': 7,
|
||||
\ 'code': 'TY002',
|
||||
\ 'text': 'Potential issue',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#ty#Handle(bufnr(''), [
|
||||
\ '[',
|
||||
\ '{"check_name":"TY001","description":"Type check failed","severity":"major","location":{"positions":{"begin":{"line":3,"column":2},"end":{"line":3,"column":10}}}},',
|
||||
\ '{"check_name":"TY002","description":"Potential issue","severity":"minor","location":{"positions":{"begin":{"line":6,"column":4},"end":{"line":6,"column":7}}}}',
|
||||
\ ']',
|
||||
\ ])
|
||||
|
||||
Execute(We should handle empty output from ty correctly):
|
||||
AssertEqual [], ale_linters#python#ty#Handle(bufnr(''), ['[]'])
|
||||
72
test/linter/test_ty.vader
Normal file
72
test/linter/test_ty.vader
Normal file
@@ -0,0 +1,72 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('python', 'ty')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The ty command callback should return the correct default values):
|
||||
call ale#test#SetFilename('./foo.py')
|
||||
|
||||
AssertLinterCwd expand('%:p:h')
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(The option for disabling changing directories should work):
|
||||
let g:ale_python_ty_change_directory = 0
|
||||
|
||||
AssertLinterCwd ''
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(The ty executable should be configurable, and escaped properly):
|
||||
let g:ale_python_ty_executable = 'executable with spaces'
|
||||
|
||||
AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(The ty command callback should let you set options):
|
||||
let g:ale_python_ty_options = '--some-option value'
|
||||
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab --some-option value %s'
|
||||
|
||||
Execute(The ty command callback should switch to project root when available):
|
||||
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir')
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(The ty command callback should use the global executable by default):
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(The ty command callback should fall back to global ty when no virtualenv executable is found):
|
||||
let g:ale_python_ty_use_global = 0
|
||||
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
|
||||
|
||||
AssertLinter 'ty', ale#Escape('ty') . ' check --output-format gitlab %s'
|
||||
|
||||
Execute(Setting executable to 'pipenv' should append 'run ty'):
|
||||
let g:ale_python_ty_executable = 'path/to/pipenv'
|
||||
|
||||
AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run ty check --output-format gitlab %s'
|
||||
|
||||
Execute(Pipenv is detected when python_ty_auto_pipenv is set):
|
||||
let g:ale_python_ty_auto_pipenv = 1
|
||||
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
|
||||
|
||||
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run ty check --output-format gitlab %s'
|
||||
|
||||
Execute(Setting executable to 'poetry' should append 'run ty'):
|
||||
let g:ale_python_ty_executable = 'path/to/poetry'
|
||||
|
||||
AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run ty check --output-format gitlab %s'
|
||||
|
||||
Execute(poetry is detected when python_ty_auto_poetry is set):
|
||||
let g:ale_python_ty_auto_poetry = 1
|
||||
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
|
||||
|
||||
AssertLinter 'poetry', ale#Escape('poetry') . ' run ty check --output-format gitlab %s'
|
||||
|
||||
Execute(uv is detected when python_ty_auto_uv is set):
|
||||
let g:ale_python_ty_auto_uv = 1
|
||||
call ale#test#SetFilename('../test-files/python/uv/whatever.py')
|
||||
|
||||
AssertLinter 'uv', ale#Escape('uv') . ' run ty check --output-format gitlab %s'
|
||||
Reference in New Issue
Block a user