diff options
author | Daniel Roseman <daniel@roseman.org.uk> | 2021-07-25 05:39:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 13:39:05 +0900 |
commit | 7d8fb2ba1716a744446b811fc278ecf30d4eb771 (patch) | |
tree | cabed5301053216ab424e6f554dc7595b1948bb3 /test | |
parent | 530b38de342a21cce330a32af0c1b66671d335c2 (diff) | |
download | ale-7d8fb2ba1716a744446b811fc278ecf30d4eb771.zip |
Python support poetry (#3834)
* Add poetry support to python linters and black fixer.
* Update python.vim to detect poetry project.
* Update ale.vim, add an option for poetry `g:ale_python_auto_poetry`.
* Update ale-python.txt, add poetry support.
* Add and update poetry related tests.
Co-authored-by: unc0 <unc0@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixers/test_black_fixer_callback.vader | 10 | ||||
-rw-r--r-- | test/linter/test_bandit.vader | 19 | ||||
-rw-r--r-- | test/linter/test_flake8.vader | 16 | ||||
-rw-r--r-- | test/linter/test_mypy.vader | 16 | ||||
-rw-r--r-- | test/linter/test_prospector.vader | 15 | ||||
-rw-r--r-- | test/linter/test_pycodestyle.vader | 13 | ||||
-rw-r--r-- | test/linter/test_pydocstyle.vader | 12 | ||||
-rw-r--r-- | test/linter/test_pyflakes.vader | 13 | ||||
-rw-r--r-- | test/linter/test_pylama.vader | 12 | ||||
-rw-r--r-- | test/linter/test_pylint.vader | 15 | ||||
-rw-r--r-- | test/linter/test_pylsp.vader | 12 | ||||
-rw-r--r-- | test/linter/test_pyre.vader | 13 | ||||
-rw-r--r-- | test/linter/test_vulture.vader | 4 | ||||
-rw-r--r-- | test/test-files/python/poetry/poetry.lock | 0 | ||||
-rw-r--r-- | test/test_python_pipenv.vader | 2 | ||||
-rw-r--r-- | test/test_python_poetry.vader | 19 |
16 files changed, 190 insertions, 1 deletions
diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader index a69eafd9..bb76a1fe 100644 --- a/test/fixers/test_black_fixer_callback.vader +++ b/test/fixers/test_black_fixer_callback.vader @@ -55,3 +55,13 @@ Execute(Pipenv is detected when python_black_auto_pipenv is set): AssertEqual \ {'command': ale#Escape('pipenv') . ' run black -'}, \ ale#fixers#black#Fix(bufnr('')) + +Execute(Poetry is detected when python_black_auto_poetry is set): + let g:ale_python_black_auto_poetry = 1 + let g:ale_python_black_change_directory = 0 + + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertEqual + \ {'command': ale#Escape('poetry') . ' run black -'}, + \ ale#fixers#black#Fix(bufnr('')) diff --git a/test/linter/test_bandit.vader b/test/linter/test_bandit.vader index 3d3a60a3..e9488c00 100644 --- a/test/linter/test_bandit.vader +++ b/test/linter/test_bandit.vader @@ -48,6 +48,25 @@ Execute(Pipenv is detected when python_bandit_auto_pipenv is set): \ . b:bandit_flags \ . ' -' +Execute(Setting executable to 'poetry' appends 'run bandit'): + let g:ale_python_bandit_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') + \ . ' run bandit' + \ . b:bandit_flags + \ . ' -' + +Execute(Poetry is detected when python_bandit_auto_poetry is set): + let g:ale_python_bandit_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') + \ . ' 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 81efe497..0b87c27b 100644 --- a/test/linter/test_flake8.vader +++ b/test/linter/test_flake8.vader @@ -199,3 +199,19 @@ Execute(Pipenv is detected when python_flake8_auto_pipenv is set): AssertLinterCwd ale#python#FindProjectRootIni(bufnr('')) AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -' + +Execute(Setting executable to 'poetry' should append 'run flake8'): + let g:ale_python_flake8_executable = 'path/to/poetry' + + " FIXME: poetry should check the version with flake8. + GivenCommandOutput [] + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run flake8 --format=default -' + +Execute(poetry is detected when python_flake8_auto_poetry is set): + let g:ale_python_flake8_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinterCwd ale#python#FindProjectRootIni(bufnr('')) + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run flake8 --format=default --stdin-display-name %s -' diff --git a/test/linter/test_mypy.vader b/test/linter/test_mypy.vader index 8c1e5e9c..bac59d92 100644 --- a/test/linter/test_mypy.vader +++ b/test/linter/test_mypy.vader @@ -88,3 +88,19 @@ Execute(Pipenv is detected when python_mypy_auto_pipenv is set): AssertLinterCwd expand('#' . bufnr('') . ':p:h') AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s' + +Execute(Setting executable to 'poetry' appends 'run mypy'): + let g:ale_python_mypy_executable = 'path/to/poetry' + + AssertLinterCwd expand('#' . bufnr('') . ':p:h') + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run mypy' + \ . ' --show-column-numbers --shadow-file %s %t %s' + +Execute(Poetry is detected when python_mypy_auto_poetry is set): + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + let g:ale_python_mypy_auto_poetry = 1 + + AssertLinterCwd expand('#' . bufnr('') . ':p:h') + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' 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 d6f84308..82e1596d 100644 --- a/test/linter/test_prospector.vader +++ b/test/linter/test_prospector.vader @@ -18,3 +18,18 @@ Execute(Pipenv is detected when python_prospector_auto_pipenv is set): AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run prospector' \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' + +Execute(Setting executable to 'poetry' appends 'run prospector'): + let g:ale_python_prospector_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run prospector' + \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' + +Execute(Poetry is detected when python_prospector_auto_poetry is set): + let g:ale_python_prospector_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run prospector' + \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s' diff --git a/test/linter/test_pycodestyle.vader b/test/linter/test_pycodestyle.vader index 9260913c..fac53d9f 100644 --- a/test/linter/test_pycodestyle.vader +++ b/test/linter/test_pycodestyle.vader @@ -31,3 +31,16 @@ Execute(Pipenv is detected when python_pycodestyle_auto_pipenv is set): AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run pycodestyle -' + +Execute(Setting executable to 'poetry' appends 'run pycodestyle'): + let g:ale_python_pycodestyle_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run pycodestyle -' + +Execute(Poetry is detected when python_pycodestyle_auto_poetry is set): + let g:ale_python_pycodestyle_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run pycodestyle -' diff --git a/test/linter/test_pydocstyle.vader b/test/linter/test_pydocstyle.vader index b24cb0d9..24d669c6 100644 --- a/test/linter/test_pydocstyle.vader +++ b/test/linter/test_pydocstyle.vader @@ -31,3 +31,15 @@ Execute(Pipenv is detected when python_pydocstyle_auto_pipenv is set): call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pydocstyle %s:t' + +Execute(Setting executable to 'poetry' appends 'run pydocstyle'): + let g:ale_python_pydocstyle_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run pydocstyle %s:t' + +Execute(Poetry is detected when python_pydocstyle_auto_poetry is set): + let g:ale_python_pydocstyle_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', ale#Escape('poetry') . ' run pydocstyle %s:t' diff --git a/test/linter/test_pyflakes.vader b/test/linter/test_pyflakes.vader index bbb7b74c..bd442098 100644 --- a/test/linter/test_pyflakes.vader +++ b/test/linter/test_pyflakes.vader @@ -44,3 +44,16 @@ Execute(Pipenv is detected when python_pyflakes_auto_pipenv is set): AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run pyflakes %t' + +Execute(Setting executable to 'poetry' appends 'run pyflakes'): + let g:ale_python_pyflakes_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run pyflakes %t', + +Execute(Poetry is detected when python_pyflakes_auto_poetry is set): + let g:ale_python_pyflakes_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run pyflakes %t' diff --git a/test/linter/test_pylama.vader b/test/linter/test_pylama.vader index 29fa971b..3c6a6efa 100644 --- a/test/linter/test_pylama.vader +++ b/test/linter/test_pylama.vader @@ -74,3 +74,15 @@ Execute(Pipenv is detected when python_pylama_auto_pipenv is set): call ale#test#SetFilename('../test-files/python/pipenv/whatever.py') AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylama' . b:command_tail + +Execute(Setting executable to 'poetry' appends 'run pylama'): + let g:ale_python_pylama_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run pylama' . b:command_tail + +Execute(poetry is detected when python_pylama_auto_poetry is set): + let g:ale_python_pylama_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', ale#Escape('poetry') . ' run pylama' . b:command_tail diff --git a/test/linter/test_pylint.vader b/test/linter/test_pylint.vader index e581915f..d15161e6 100644 --- a/test/linter/test_pylint.vader +++ b/test/linter/test_pylint.vader @@ -79,3 +79,18 @@ Execute(Pipenv is detected when python_pylint_auto_pipenv is set): AssertLinterCwd expand('%:p:h') AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylint' \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' + +Execute(Setting executable to 'poetry' appends 'run pylint'): + let g:ale_python_pylint_executable = 'path/to/poetry' + let g:ale_python_pylint_use_global = 1 + + AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run pylint' + \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' + +Execute(poetry is detected when python_pylint_auto_poetry is set): + let g:ale_python_pylint_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + 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' diff --git a/test/linter/test_pylsp.vader b/test/linter/test_pylsp.vader index 9d7d0775..acee2c3f 100644 --- a/test/linter/test_pylsp.vader +++ b/test/linter/test_pylsp.vader @@ -51,6 +51,18 @@ Execute(Pipenv is detected when python_pylsp_auto_pipenv is set): AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run pylsp' +Execute(Setting executable to 'poetry' appends 'run pylsp'): + let g:ale_python_pylsp_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run pylsp' + +Execute(poetry is detected when python_pylsp_auto_poetry is set): + let g:ale_python_pylsp_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' 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 d3e5fe9d..335e31f2 100644 --- a/test/linter/test_pyre.vader +++ b/test/linter/test_pyre.vader @@ -44,3 +44,16 @@ Execute(Pipenv is detected when python_pyre_auto_pipenv is set): AssertLinter 'pipenv', \ ale#Escape('pipenv') . ' run pyre persistent' + +Execute(Setting executable to 'poetry' appends 'run pyre'): + let g:ale_python_pyre_executable = 'path/to/poetry' + + AssertLinter 'path/to/poetry', + \ ale#Escape('path/to/poetry') . ' run pyre persistent' + +Execute(Poetry is detected when python_pyre_auto_poetry is set): + let g:ale_python_pyre_auto_poetry = 1 + call ale#test#SetFilename('../test-files/python/poetry/whatever.py') + + AssertLinter 'poetry', + \ ale#Escape('poetry') . ' run pyre persistent' diff --git a/test/linter/test_vulture.vader b/test/linter/test_vulture.vader index 74709c9e..78655bd7 100644 --- a/test/linter/test_vulture.vader +++ b/test/linter/test_vulture.vader @@ -56,3 +56,7 @@ Execute(Setting executable to 'pipenv' appends 'run vulture'): let g:ale_python_vulture_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run vulture' . ' .' +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' . ' .' diff --git a/test/test-files/python/poetry/poetry.lock b/test/test-files/python/poetry/poetry.lock new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/python/poetry/poetry.lock diff --git a/test/test_python_pipenv.vader b/test/test_python_pipenv.vader index 8b1e9ab0..041e2874 100644 --- a/test/test_python_pipenv.vader +++ b/test/test_python_pipenv.vader @@ -11,7 +11,7 @@ Execute(ale#python#PipenvPresent is true when a pipenv environment is present): \ ale#python#PipenvPresent(bufnr('%')), \ 1 -Execute(ale#python#PipenvPresent is false true when no pipenv environment is present): +Execute(ale#python#PipenvPresent is false when no pipenv environment is present): call ale#test#SetFilename('test-files/python/no_pipenv/whatever.py') AssertEqual diff --git a/test/test_python_poetry.vader b/test/test_python_poetry.vader new file mode 100644 index 00000000..8197b786 --- /dev/null +++ b/test/test_python_poetry.vader @@ -0,0 +1,19 @@ +Before: + call ale#test#SetDirectory('/testplugin/test') + +After: + call ale#test#RestoreDirectory() + +Execute(ale#python#poetryPresent is true when a poetry environment is present): + call ale#test#SetFilename('test-files/python/poetry/whatever.py') + + AssertEqual + \ ale#python#PoetryPresent(bufnr('%')), + \ 1 + +Execute(ale#python#poetryPresent is false when no poetry environment is present): + call ale#test#SetFilename('test-files/python/no_poetry/whatever.py') + + AssertEqual + \ ale#python#PoetryPresent(bufnr('%')), + \ 0 |