]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_unimport.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / ale / test / linter / test_unimport.vader
1 Before:
2   call ale#assert#SetUpLinterTest('python', 'unimport')
3   call ale#test#SetFilename('test.py')
4
5   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
6
7 After:
8   unlet! b:executable
9   unlet! b:bin_dir
10
11   call ale#assert#TearDownLinterTest()
12
13 Execute(The unimport callbacks should return the correct default values):
14   AssertLinter 'unimport', ale#Escape('unimport') . ' --check %t'
15
16 Execute(The unimport executable should be configurable, and escaped properly):
17   let b:ale_python_unimport_executable = 'foobar'
18
19   AssertLinter 'foobar', ale#Escape('foobar') . ' --check %t'
20
21 Execute(The unimport command callback should let you set options):
22   let b:ale_python_unimport_options = '--gitignore'
23
24   AssertLinter 'unimport', ale#Escape('unimport') . ' --gitignore --check %t'
25
26 Execute(The unimport command should switch directories to the detected project root):
27   call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
28
29   AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir')
30   AssertLinter 'unimport', ale#Escape('unimport') . ' --check %t'
31
32 Execute(The unimport callbacks should detect virtualenv directories and switch to the project root):
33   call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
34
35   let b:executable = ale#path#Simplify(
36   \ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/unimport'
37   \)
38
39   AssertLinter b:executable, ale#Escape(b:executable) . ' --check %t'
40
41 Execute(You should able able to use the global unimport instead):
42   call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
43   let g:ale_python_unimport_use_global = 1
44
45   AssertLinter 'unimport', ale#Escape('unimport') . ' --check %t'
46
47 Execute(Setting executable to 'pipenv' appends 'run unimport'):
48   let g:ale_python_unimport_executable = 'path/to/pipenv'
49
50   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
51   AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run unimport --check %t'
52
53 Execute(Pipenv is detected when python_unimport_auto_pipenv is set):
54   call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
55   let g:ale_python_unimport_auto_pipenv = 1
56
57   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
58   AssertLinter 'pipenv', ale#Escape('pipenv') . ' run unimport --check %t'
59
60 Execute(Setting executable to 'poetry' appends 'run unimport'):
61   let g:ale_python_unimport_executable = 'path/to/poetry'
62
63   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
64   AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run unimport --check %t'
65
66 Execute(Poetry is detected when python_unimport_auto_poetry is set):
67   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
68   let g:ale_python_unimport_auto_poetry = 1
69
70   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
71   AssertLinter 'poetry', ale#Escape('poetry') . ' run unimport --check %t'
72
73 Execute(uv is detected when python_unimport_auto_uv is set):
74   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
75   let g:ale_python_unimport_auto_uv = 1
76
77   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
78   AssertLinter 'uv', ale#Escape('uv') . ' run unimport --check %t'