diff options
author | Diego Henrique Oliveira <contato@diegoholiveira.com> | 2024-09-05 03:37:30 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 15:37:30 +0900 |
commit | a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2 (patch) | |
tree | 537f36c4c8d5bdaeb10eb29ffc5bb8e18ef55065 /test | |
parent | 954682108d21b412561fb32e3fa766c7ee539984 (diff) | |
download | ale-a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2.zip |
Improve support for python package manage: pipenv, poetry and uv (#4825)
Diffstat (limited to 'test')
34 files changed, 426 insertions, 42 deletions
diff --git a/test/fixers/test_autoflake_fixer_callback.vader b/test/fixers/test_autoflake_fixer_callback.vader index 91fc62b5..2abe5fc7 100644 --- a/test/fixers/test_autoflake_fixer_callback.vader +++ b/test/fixers/test_autoflake_fixer_callback.vader @@ -18,32 +18,52 @@ After: call ale#test#RestoreDirectory() -Execute(The autoflake callback should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#autoflake#Fix(bufnr('')) +Execute(The autoflake callback should include options): + let g:ale_python_autoflake_options = '--some-option' silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') AssertEqual \ { \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoflake')) + \ . ' --some-option' \ . ' --in-place ' \ . ' %t', \ 'read_temporary_file': 1, \ }, \ ale#fixers#autoflake#Fix(bufnr('')) +Execute(pipenv is detected when python_autoflake_auto_pipenv is set): + let g:ale_python_autoflake_auto_pipenv = 1 -Execute(The autoflake callback should include options): - let g:ale_python_autoflake_options = '--some-option' + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') - silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') AssertEqual \ { - \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoflake')) - \ . ' --some-option' - \ . ' --in-place ' - \ . ' %t', + \ 'command': ale#Escape('pipenv') . ' run autoflake --in-place %t', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#autoflake#Fix(bufnr('')) + +Execute(Poetry is detected when python_autoflake_auto_poetry is set): + let g:ale_python_autoflake_auto_poetry = 1 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('poetry') . ' run autoflake --in-place %t', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#autoflake#Fix(bufnr('')) + +Execute(uv is detected when python_autoflake_auto_uv is set): + let g:ale_python_autoflake_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('uv') . ' run autoflake --in-place %t', \ 'read_temporary_file': 1, \ }, \ ale#fixers#autoflake#Fix(bufnr('')) diff --git a/test/fixers/test_autoimport_fixer_callback.vader b/test/fixers/test_autoimport_fixer_callback.vader index edca5c38..785f4f65 100644 --- a/test/fixers/test_autoimport_fixer_callback.vader +++ b/test/fixers/test_autoimport_fixer_callback.vader @@ -18,11 +18,8 @@ After: 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 . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ { \ 'cwd': '%s:h', @@ -33,11 +30,8 @@ Execute(The autoimport callback should return the correct default values): 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 . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ { \ 'cwd': '%s:h', @@ -45,3 +39,39 @@ Execute(The autoimport callback should respect custom options): \ . ' --multi-line=3 --trailing-comma -', \ }, \ ale#fixers#autoimport#Fix(bufnr('')) + +Execute(pipenv is detected when python_autoimport_auto_pipenv is set): + let g:ale_python_autoimport_auto_pipenv = 1 + + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') + + AssertEqual + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('pipenv') . ' run autoimport -', + \ }, + \ ale#fixers#autoimport#Fix(bufnr('')) + +Execute(Poetry is detected when python_autoimport_auto_poetry is set): + let g:ale_python_autoimport_auto_poetry = 1 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('poetry') . ' run autoimport -', + \ }, + \ ale#fixers#autoimport#Fix(bufnr('')) + +Execute(uv is detected when python_autoimport_auto_uv is set): + let g:ale_python_autoimport_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('uv') . ' run autoimport -', + \ }, + \ ale#fixers#autoimport#Fix(bufnr('')) diff --git a/test/fixers/test_autopep8_fixer_callback.vader b/test/fixers/test_autopep8_fixer_callback.vader index 46671eda..094677f3 100644 --- a/test/fixers/test_autopep8_fixer_callback.vader +++ b/test/fixers/test_autopep8_fixer_callback.vader @@ -19,11 +19,8 @@ After: call ale#test#RestoreDirectory() Execute(The autopep8 callback should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#autopep8#Fix(bufnr('')) - silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' -'}, \ ale#fixers#autopep8#Fix(bufnr('')) @@ -32,6 +29,40 @@ Execute(The autopep8 callback should include options): let g:ale_python_autopep8_options = '--some-option' silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' --some-option -' }, \ ale#fixers#autopep8#Fix(bufnr('')) + +Execute(pipenv is detected when python_autopep8_auto_pipenv is set): + let g:ale_python_autopep8_auto_pipenv = 1 + + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('pipenv') . ' run autopep8 -', + \ }, + \ ale#fixers#autopep8#Fix(bufnr('')) + +Execute(Poetry is detected when python_autopep8_auto_poetry is set): + let g:ale_python_autopep8_auto_poetry = 1 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('poetry') . ' run autopep8 -', + \ }, + \ ale#fixers#autopep8#Fix(bufnr('')) + +Execute(uv is detected when python_autopep8_auto_uv is set): + let g:ale_python_autopep8_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('uv') . ' run autopep8 -', + \ }, + \ ale#fixers#autopep8#Fix(bufnr('')) diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader index bb76a1fe..079f5f8f 100644 --- a/test/fixers/test_black_fixer_callback.vader +++ b/test/fixers/test_black_fixer_callback.vader @@ -65,3 +65,13 @@ Execute(Poetry is detected when python_black_auto_poetry is set): AssertEqual \ {'command': ale#Escape('poetry') . ' run black -'}, \ ale#fixers#black#Fix(bufnr('')) + +Execute(uv is detected when python_black_auto_uv is set): + let g:ale_python_black_auto_uv = 1 + let g:ale_python_black_change_directory = 0 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ {'command': ale#Escape('uv') . ' run black -'}, + \ ale#fixers#black#Fix(bufnr('')) diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader index 8b665d6b..ce42dca6 100644 --- a/test/fixers/test_isort_fixer_callback.vader +++ b/test/fixers/test_isort_fixer_callback.vader @@ -58,6 +58,19 @@ Execute(Poetry is detected when python_isort_auto_poetry is set): \ 'command': ale#Escape('poetry') . ' run isort' . ' --filename %s' . ' -' \ } +Execute(uv is detected when python_isort_auto_uv is set): + let g:ale_python_isort_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + GivenCommandOutput ['VERSION 5.7.0'] + AssertFixer + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('uv') . ' run isort' . ' --filename %s' . ' -' + \ } + + Execute(The isort callback should not use --filename for older versions): silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') diff --git a/test/fixers/test_pycln_fixer_callback.vader b/test/fixers/test_pycln_fixer_callback.vader index 30cfaa3b..b0fb22b9 100644 --- a/test/fixers/test_pycln_fixer_callback.vader +++ b/test/fixers/test_pycln_fixer_callback.vader @@ -106,6 +106,19 @@ Execute(Poetry is detected when python_pycln_auto_poetry is set, and cwd respect \ 'command': ale#Escape('poetry') . ' run pycln' . b:cmd_tail . ' -' \ } +Execute(uv is detected when python_pycln_auto_uv is set): + let g:ale_python_pycln_auto_uv = 1 + let g:ale_python_pycln_change_directory = 0 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + GivenCommandOutput ['pycln, version 1.3.0'] + AssertFixer + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('uv') . ' run pycln' . b:cmd_tail . ' -' + \ } + Execute(configuration files set in _config should be supported): let g:ale_python_pycln_change_directory = 0 let g:ale_python_pycln_config_file = ale#path#Simplify(g:dir . '/../test-files/pycln/other_config.xml') diff --git a/test/fixers/test_pyflyby_fixer_callback.vader b/test/fixers/test_pyflyby_fixer_callback.vader index d017572e..4dcf16d5 100644 --- a/test/fixers/test_pyflyby_fixer_callback.vader +++ b/test/fixers/test_pyflyby_fixer_callback.vader @@ -36,3 +36,14 @@ Execute(Poetry is detected when python_pyflyby_auto_poetry is set): \ { \ 'command': ale#Escape('poetry') . ' run tidy-imports' \ } + +Execute(uv is detected when python_pyflyby_auto_uv is set): + let g:ale_python_pyflyby_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + GivenCommandOutput ['VERSION 5.7.0'] + AssertFixer + \ { + \ 'command': ale#Escape('uv') . ' run tidy-imports' + \ } diff --git a/test/fixers/test_reorder_python_imports_fixer_callback.vader b/test/fixers/test_reorder_python_imports_fixer_callback.vader index ead2da77..82e4b84d 100644 --- a/test/fixers/test_reorder_python_imports_fixer_callback.vader +++ b/test/fixers/test_reorder_python_imports_fixer_callback.vader @@ -18,11 +18,8 @@ After: call ale#test#RestoreDirectory() Execute(The reorder_python_imports callback should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#reorder_python_imports#Fix(bufnr('')) - silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ { \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' @@ -33,14 +30,44 @@ Execute(The reorder_python_imports callback should return the correct default va Execute(The reorder_python_imports callback should respect custom options): let g:ale_python_reorder_python_imports_options = '--py3-plus' - AssertEqual - \ 0, - \ ale#fixers#reorder_python_imports#Fix(bufnr('')) - silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py') + AssertEqual \ { \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' \ . b:bin_dir . '/reorder-python-imports')) . ' --py3-plus -', \ }, \ ale#fixers#reorder_python_imports#Fix(bufnr('')) + +Execute(pipenv is detected when python_reorder_python_imports_auto_pipenv is set): + let g:ale_python_reorder_python_imports_auto_pipenv = 1 + + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('pipenv') . ' run reorder-python-imports -', + \ }, + \ ale#fixers#reorder_python_imports#Fix(bufnr('')) + +Execute(Poetry is detected when python_reorder_python_imports_auto_poetry is set): + let g:ale_python_reorder_python_imports_auto_poetry = 1 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('poetry') . ' run reorder-python-imports -', + \ }, + \ ale#fixers#reorder_python_imports#Fix(bufnr('')) + +Execute(uv is detected when python_reorder_python_imports_auto_uv is set): + let g:ale_python_reorder_python_imports_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('uv') . ' run reorder-python-imports -', + \ }, + \ ale#fixers#reorder_python_imports#Fix(bufnr('')) diff --git a/test/fixers/test_ruff_fixer_callback.vader b/test/fixers/test_ruff_fixer_callback.vader index abe5860e..82a0383a 100644 --- a/test/fixers/test_ruff_fixer_callback.vader +++ b/test/fixers/test_ruff_fixer_callback.vader @@ -134,3 +134,17 @@ Execute(Poetry is detected when python_ruff_auto_poetry is set, and cwd respects \ 'command': ale#Escape('poetry') . ' run ruff --stdin-filename ' . fname . ' --fix -' \ } +Execute(uv is detected when python_ruff_auto_uv is set): + let g:ale_python_ruff_auto_uv = 1 + let g:ale_python_ruff_change_directory = 0 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py')) + + GivenCommandOutput ['ruff 0.0.72'] + AssertFixer + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('uv') . ' run ruff --stdin-filename ' . fname . ' --fix -' + \ } diff --git a/test/fixers/test_ruff_format_fixer_callback.vader b/test/fixers/test_ruff_format_fixer_callback.vader index 3cf5fd52..7672ee3e 100644 --- a/test/fixers/test_ruff_format_fixer_callback.vader +++ b/test/fixers/test_ruff_format_fixer_callback.vader @@ -84,3 +84,16 @@ Execute(Poetry is detected when python_ruff_format_auto_poetry is set, and cwd r \ 'command': ale#Escape('poetry') . ' run ruff format --stdin-filename ' . fname . ' -' \ } +Execute(uv is detected when python_ruff_format_auto_uv is set): + let g:ale_python_ruff_format_auto_uv = 1 + let g:ale_python_ruff_format_change_directory = 0 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py')) + + AssertFixer + \ { + \ 'cwd': '%s:h', + \ 'command': ale#Escape('uv') . ' run ruff format --stdin-filename ' . fname . ' -' + \ } diff --git a/test/fixers/test_yapf_fixer_callback.vader b/test/fixers/test_yapf_fixer_callback.vader index a7fcc07b..8d88d423 100644 --- a/test/fixers/test_yapf_fixer_callback.vader +++ b/test/fixers/test_yapf_fixer_callback.vader @@ -15,17 +15,6 @@ After: call ale#test#RestoreDirectory() -Execute(The yapf callback should return the correct default values): - AssertEqual - \ 0, - \ ale#fixers#yapf#Fix(bufnr('')) - - call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py') - - AssertEqual - \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/yapf'))}, - \ ale#fixers#yapf#Fix(bufnr('')) - \ Execute(The yapf should include the .style.yapf file if present): call ale#test#SetFilename('../test-files/python/with_virtualenv/dir_with_yapf_config/foo/bar.py') @@ -37,3 +26,36 @@ Execute(The yapf should include the .style.yapf file if present): \ . ' --style ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/dir_with_yapf_config/.style.yapf')), \ }, \ ale#fixers#yapf#Fix(bufnr('')) + +Execute(pipenv is detected when python_yapf_auto_pipenv is set): + let g:ale_python_yapf_auto_pipenv = 1 + + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('pipenv') . ' run yapf', + \ }, + \ ale#fixers#yapf#Fix(bufnr('')) + +Execute(Poetry is detected when python_yapf_auto_poetry is set): + let g:ale_python_yapf_auto_poetry = 1 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('poetry') . ' run yapf', + \ }, + \ ale#fixers#yapf#Fix(bufnr('')) + +Execute(uv is detected when python_yapf_auto_uv is set): + let g:ale_python_yapf_auto_uv = 1 + + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertEqual + \ { + \ 'command': ale#Escape('uv') . ' run yapf', + \ }, + \ ale#fixers#yapf#Fix(bufnr('')) diff --git a/test/linter/test_bandit.vader b/test/linter/test_bandit.vader index e9488c00..803e3bf2 100644 --- a/test/linter/test_bandit.vader +++ b/test/linter/test_bandit.vader @@ -67,6 +67,16 @@ Execute(Poetry is detected when python_bandit_auto_poetry is set): \ . b:bandit_flags \ . ' -' +Execute(uv is used when python_bandit_auto_uv is set): + let g:ale_python_bandit_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') + \ . ' run bandit' + \ . b:bandit_flags + \ . ' -' + Execute(The bandit command callback should add .bandit by default): silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_bandit/namespace/foo/bar.py') diff --git a/test/linter/test_flake8.vader b/test/linter/test_flake8.vader index 53b40b29..d59c9e06 100644 --- a/test/linter/test_flake8.vader +++ b/test/linter/test_flake8.vader @@ -217,3 +217,10 @@ Execute(poetry is detected when python_flake8_auto_poetry is set): AssertLinterCwd ale#python#FindProjectRootIni(bufnr('')) AssertLinter 'poetry', \ ale#Escape('poetry') . ' run flake8 --format=default --stdin-display-name %s -' + +Execute(uv is detected when python_flake8_auto_uv is set): + let g:ale_python_flake8_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run flake8 --format=default --stdin-display-name %s -' diff --git a/test/linter/test_flakehell.vader b/test/linter/test_flakehell.vader index 98314408..8a159f0d 100644 --- a/test/linter/test_flakehell.vader +++ b/test/linter/test_flakehell.vader @@ -201,3 +201,10 @@ Execute(poetry is detected when python_flakehell_auto_poetry is set): AssertLinterCwd ale#python#FindProjectRootIni(bufnr('')) AssertLinter 'poetry', \ ale#Escape('poetry') . ' run flakehell lint --format=default --stdin-display-name %s -' + +Execute(uv is detected when python_flakehell_auto_uv is set): + let g:ale_python_flakehell_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run flakehell lint --format=default --stdin-display-name %s -' diff --git a/test/linter/test_jedils.vader b/test/linter/test_jedils.vader index 5ffd22d8..a86d80d6 100644 --- a/test/linter/test_jedils.vader +++ b/test/linter/test_jedils.vader @@ -47,3 +47,17 @@ Execute(Setting executable to 'pipenv' appends 'run jedi-language-server'): call ale#test#SetFilename('../test-files/dummy') AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run jedi-language-server' + +Execute(poetry is detected when python_jedils_auto_poetry is set): + let g:ale_python_jedils_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run jedi-language-server' + +Execute(uv is detected when python_jedils_auto_uv is set): + let g:ale_python_jedils_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run jedi-language-server' diff --git a/test/linter/test_mypy.vader b/test/linter/test_mypy.vader index bac59d92..3cad6c3e 100644 --- a/test/linter/test_mypy.vader +++ b/test/linter/test_mypy.vader @@ -104,3 +104,11 @@ Execute(Poetry is detected when python_mypy_auto_poetry is set): AssertLinterCwd expand('#' . bufnr('') . ':p:h') AssertLinter 'poetry', \ ale#Escape('poetry') . ' run mypy --show-column-numbers --shadow-file %s %t %s' + +Execute(uv is detected when python_mypy_auto_uv is set): + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + let g:ale_python_mypy_auto_uv = 1 + + AssertLinterCwd expand('#' . bufnr('') . ':p:h') + AssertLinter 'uv', + \ ale#Escape('uv') . ' run mypy --show-column-numbers --shadow-file %s %t %s' diff --git a/test/linter/test_prospector.vader b/test/linter/test_prospector.vader index 82e1596d..934849a7 100644 --- a/test/linter/test_prospector.vader +++ b/test/linter/test_prospector.vader @@ -33,3 +33,11 @@ Execute(Poetry is detected when python_prospector_auto_poetry is set): AssertLinter 'poetry', \ ale#Escape('poetry') . ' run prospector' \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' + +Execute(uv is detected when python_prospector_auto_uv is set): + let g:ale_python_prospector_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run prospector' + \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' diff --git a/test/linter/test_pycln.vader b/test/linter/test_pycln.vader index eb04f3d5..3d48ee7b 100644 --- a/test/linter/test_pycln.vader +++ b/test/linter/test_pycln.vader @@ -97,6 +97,14 @@ Execute(poetry is detected when python_pycln_auto_poetry is set): AssertLinter 'poetry', ale#Escape('poetry') . ' run pycln' \ . b:cmd_tail +Execute(uv is detected when python_pycln_auto_uv is set): + let g:ale_python_pycln_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinterCwd expand('%:p:h') + AssertLinter 'uv', ale#Escape('uv') . ' run pycln' + \ . b:cmd_tail + Execute(configuration files set in _config should be supported): let g:ale_python_pycln_config_file = ale#path#Simplify(g:dir . '/../test-files/pycln/other_config.xml') diff --git a/test/linter/test_pycodestyle.vader b/test/linter/test_pycodestyle.vader index fac53d9f..85983122 100644 --- a/test/linter/test_pycodestyle.vader +++ b/test/linter/test_pycodestyle.vader @@ -44,3 +44,10 @@ Execute(Poetry is detected when python_pycodestyle_auto_poetry is set): AssertLinter 'poetry', \ ale#Escape('poetry') . ' run pycodestyle -' + +Execute(uv is detected when python_pycodestyle_auto_uv is set): + let g:ale_python_pycodestyle_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run pycodestyle -' diff --git a/test/linter/test_pydocstyle.vader b/test/linter/test_pydocstyle.vader index fc7fbbf2..cdc36885 100644 --- a/test/linter/test_pydocstyle.vader +++ b/test/linter/test_pydocstyle.vader @@ -43,3 +43,9 @@ Execute(Poetry is detected when python_pydocstyle_auto_poetry is set): call ale#test#SetFilename('../test-files/python/poetry/whatever.py') AssertLinter 'poetry', ale#Escape('poetry') . ' run pydocstyle %s' + +Execute(uv is detected when python_pydocstyle_auto_uv is set): + let g:ale_python_pydocstyle_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', ale#Escape('uv') . ' run pydocstyle %s' diff --git a/test/linter/test_pyflakes.vader b/test/linter/test_pyflakes.vader index 61aee562..09272620 100644 --- a/test/linter/test_pyflakes.vader +++ b/test/linter/test_pyflakes.vader @@ -58,3 +58,10 @@ Execute(Poetry is detected when python_pyflakes_auto_poetry is set): AssertLinter 'poetry', \ ale#Escape('poetry') . ' run pyflakes %t' + +Execute(uv is detected when python_pyflakes_auto_uv is set): + let g:ale_python_pyflakes_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run pyflakes %t' diff --git a/test/linter/test_pylama.vader b/test/linter/test_pylama.vader index 3c6a6efa..6e0aa293 100644 --- a/test/linter/test_pylama.vader +++ b/test/linter/test_pylama.vader @@ -86,3 +86,9 @@ Execute(poetry is detected when python_pylama_auto_poetry is set): call ale#test#SetFilename('../test-files/python/poetry/whatever.py') AssertLinter 'poetry', ale#Escape('poetry') . ' run pylama' . b:command_tail + +Execute(uv is detected when python_pylama_auto_uv is set): + let g:ale_python_pylama_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', ale#Escape('uv') . ' run pylama' . b:command_tail diff --git a/test/linter/test_pylint.vader b/test/linter/test_pylint.vader index d15161e6..73e792fb 100644 --- a/test/linter/test_pylint.vader +++ b/test/linter/test_pylint.vader @@ -94,3 +94,11 @@ Execute(poetry is detected when python_pylint_auto_poetry is set): AssertLinterCwd expand('%:p:h') AssertLinter 'poetry', ale#Escape('poetry') . ' run pylint' \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' + +Execute(uv is detected when python_pylint_auto_uv is set): + let g:ale_python_pylint_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinterCwd expand('%:p:h') + AssertLinter 'uv', ale#Escape('uv') . ' run pylint' + \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' diff --git a/test/linter/test_pylsp.vader b/test/linter/test_pylsp.vader index c46c53a4..dd92d70a 100644 --- a/test/linter/test_pylsp.vader +++ b/test/linter/test_pylsp.vader @@ -85,6 +85,13 @@ Execute(poetry is detected when python_pylsp_auto_poetry is set): AssertLinter 'poetry', \ ale#Escape('poetry') . ' run pylsp' +Execute(uv is detected when python_pylsp_auto_uv is set): + let g:ale_python_pylsp_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run pylsp' + Execute(Should accept configuration settings): AssertLSPConfig {} let b:ale_python_pylsp_config = {'pylsp': {'plugins': {'preload': {'enabled': v:false}}}} diff --git a/test/linter/test_pyre.vader b/test/linter/test_pyre.vader index 053ef12f..c46bc034 100644 --- a/test/linter/test_pyre.vader +++ b/test/linter/test_pyre.vader @@ -61,6 +61,13 @@ Execute(Poetry is detected when python_pyre_auto_poetry is set): AssertLinter 'poetry', \ ale#Escape('poetry') . ' run pyre persistent' +Execute(uv is detected when python_pyre_auto_uv is set): + let g:ale_python_pyre_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run pyre persistent' + Execute(The FindProjectRoot should detect the project root directory for namespace package via .pyre_configuration.local): silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/pyre_configuration_dir/foo/bar.py') diff --git a/test/linter/test_pyright.vader b/test/linter/test_pyright.vader index 45e9765e..91a715e2 100644 --- a/test/linter/test_pyright.vader +++ b/test/linter/test_pyright.vader @@ -179,3 +179,10 @@ Execute(poetry is detected when python_pyright_auto_poetry is set): AssertLinterCwd ale#python#FindProjectRootIni(bufnr('')) AssertLinter 'poetry', \ ale#Escape('poetry') . ' run pyright-langserver --stdio' + +Execute(uv is detected when python_pyright_auto_uv is set): + let g:ale_python_pyright_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run pyright-langserver --stdio' diff --git a/test/linter/test_refurb.vader b/test/linter/test_refurb.vader index a1f066eb..c36fe49c 100644 --- a/test/linter/test_refurb.vader +++ b/test/linter/test_refurb.vader @@ -83,3 +83,10 @@ Execute(poetry is detected when python_refurb_auto_poetry is set): AssertLinterCwd expand('%:p:h') AssertLinter 'poetry', ale#Escape('poetry') . ' run refurb %s' + +Execute(uv is detected when python_refurb_auto_uv is set): + let g:ale_python_refurb_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinterCwd expand('%:p:h') + AssertLinter 'uv', ale#Escape('uv') . ' run refurb %s' diff --git a/test/linter/test_ruff.vader b/test/linter/test_ruff.vader index bca2af75..07f3b1c4 100644 --- a/test/linter/test_ruff.vader +++ b/test/linter/test_ruff.vader @@ -117,3 +117,11 @@ Execute(poetry is detected when python_ruff_auto_poetry is set): AssertLinterCwd expand('%:p:h') AssertLinter 'poetry', ale#Escape('poetry') . ' run ruff -q --no-fix' \ . b:command_tail + +Execute(uv is detected when python_ruff_auto_uv is set): + let g:ale_python_ruff_auto_uv = 1 + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + + AssertLinterCwd expand('%:p:h') + AssertLinter 'uv', ale#Escape('uv') . ' run ruff -q --no-fix' + \ . b:command_tail diff --git a/test/linter/test_unimport.vader b/test/linter/test_unimport.vader index a5607ce9..9e8e9112 100644 --- a/test/linter/test_unimport.vader +++ b/test/linter/test_unimport.vader @@ -69,3 +69,10 @@ Execute(Poetry is detected when python_unimport_auto_poetry is set): AssertLinterCwd expand('#' . bufnr('') . ':p:h') AssertLinter 'poetry', ale#Escape('poetry') . ' run unimport --check %t' + +Execute(uv is detected when python_unimport_auto_uv is set): + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + let g:ale_python_unimport_auto_uv = 1 + + AssertLinterCwd expand('#' . bufnr('') . ':p:h') + AssertLinter 'uv', ale#Escape('uv') . ' run unimport --check %t' diff --git a/test/linter/test_vulture.vader b/test/linter/test_vulture.vader index 94e61158..abc8514b 100644 --- a/test/linter/test_vulture.vader +++ b/test/linter/test_vulture.vader @@ -61,3 +61,25 @@ Execute(Setting executable to 'poetry' appends 'run vulture'): let g:ale_python_vulture_executable = 'path/to/poetry' AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run vulture' . ' .' + +Execute(pipenv is detected when python_vulture_auto_pipenv is set): + call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') + let g:ale_python_vulture_auto_pipenv = 1 + + AssertLinter 'pipenv', + \ ale#Escape('pipenv') . ' run vulture' . ' .' + + +Execute(poetry is detected when python_vulture_auto_poetry is set): + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + let g:ale_python_vulture_auto_poetry = 1 + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run vulture' . ' .' + +Execute(uv is detected when python_vulture_auto_uv is set): + call ale#test#SetFilename('../test-files/python/uv/whatever.py') + let g:ale_python_vulture_auto_uv = 1 + + AssertLinter 'uv', + \ ale#Escape('uv') . ' run vulture' . ' .' diff --git a/test/test-files/python/uv/.gitkeep b/test/test-files/python/uv/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/python/uv/.gitkeep diff --git a/test/test-files/python/uv/uv.lock b/test/test-files/python/uv/uv.lock new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/python/uv/uv.lock diff --git a/test/test-files/python/uv/whatever.py b/test/test-files/python/uv/whatever.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/python/uv/whatever.py diff --git a/test/test_python_uv.vader b/test/test_python_uv.vader new file mode 100644 index 00000000..11d202fd --- /dev/null +++ b/test/test_python_uv.vader @@ -0,0 +1,19 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + +After: + call ale#test#RestoreDirectory() + +Execute(ale#python#UvPresent is true when a uv environment is present): + call ale#test#SetFilename('test-files/python/uv/whatever.py') + + AssertEqual + \ ale#python#UvPresent(bufnr('%')), + \ 1 + +Execute(ale#python#UvPresent is false when no uv environment is present): + call ale#test#SetFilename('test-files/python/no_uv/whatever.py') + + AssertEqual + \ ale#python#UvPresent(bufnr('%')), + \ 0 |