diff options
author | w0rp <w0rp@users.noreply.github.com> | 2020-11-21 20:45:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-21 20:45:51 +0000 |
commit | b4550f361bc0d8d0cce81ecc02c82167b6df0738 (patch) | |
tree | 376d866381a40fbea3eb51ea45709feb599ccaad /test/fixers | |
parent | b09ccc12c3001b4d551d35cb0c4195793d9b6d10 (diff) | |
parent | 513e6ee972ea4ee57b28b8b8c10e0b89bb674f25 (diff) | |
download | ale-b4550f361bc0d8d0cce81ecc02c82167b6df0738.zip |
Merge pull request #3409 from lyz-code/feat/add-autoimport-support
feat: add autoimport fixer
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_autoimport_fixer_callback.vader | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/fixers/test_autoimport_fixer_callback.vader b/test/fixers/test_autoimport_fixer_callback.vader new file mode 100644 index 00000000..6952cbb8 --- /dev/null +++ b/test/fixers/test_autoimport_fixer_callback.vader @@ -0,0 +1,50 @@ +Before: + Save g:ale_python_autoimport_executable + Save g:ale_python_autoimport_options + + " Use an invalid global executable, so we don't match it. + let g:ale_python_autoimport_executable = 'xxxinvalid' + let g:ale_python_autoimport_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + silent cd .. + silent cd command_callback + let g:dir = getcwd() + + let b:bin_dir = has('win32') ? 'Scripts' : 'bin' + +After: + Restore + + unlet! b:bin_dir + + call ale#test#RestoreDirectory() + +Execute(The autoimport callback should return the correct default values): + AssertEqual + \ 0, + \ ale#fixers#autoimport#Fix(bufnr('')) + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ { + \ 'command': ale#path#BufferCdString(bufnr('')) + \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport')) . ' -', + \ }, + \ ale#fixers#autoimport#Fix(bufnr('')) + +Execute(The autoimport callback should respect custom options): + let g:ale_python_autoimport_options = '--multi-line=3 --trailing-comma' + + AssertEqual + \ 0, + \ ale#fixers#autoimport#Fix(bufnr('')) + + silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py') + AssertEqual + \ { + \ 'command': ale#path#BufferCdString(bufnr('')) + \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport')) + \ . ' --multi-line=3 --trailing-comma -', + \ }, + \ ale#fixers#autoimport#Fix(bufnr('')) |