]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/fixers/test_autoimport_fixer_callback.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / test / fixers / test_autoimport_fixer_callback.vader
1 Before:
2   Save g:ale_python_autoimport_executable
3   Save g:ale_python_autoimport_options
4
5   " Use an invalid global executable, so we don't match it.
6   let g:ale_python_autoimport_executable = 'xxxinvalid'
7   let g:ale_python_autoimport_options = ''
8
9   call ale#test#SetDirectory('/testplugin/test/fixers')
10
11   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
12
13 After:
14   Restore
15
16   unlet! b:bin_dir
17
18   call ale#test#RestoreDirectory()
19
20 Execute(The autoimport callback should return the correct default values):
21   silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
22
23   AssertEqual
24   \ {
25   \   'cwd': '%s:h',
26   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoimport')) . ' -',
27   \ },
28   \ ale#fixers#autoimport#Fix(bufnr(''))
29
30 Execute(The autoimport callback should respect custom options):
31   let g:ale_python_autoimport_options = '--multi-line=3 --trailing-comma'
32
33   silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
34
35   AssertEqual
36   \ {
37   \   'cwd': '%s:h',
38   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoimport'))
39   \     . ' --multi-line=3 --trailing-comma -',
40   \ },
41   \ ale#fixers#autoimport#Fix(bufnr(''))
42
43 Execute(pipenv is detected when python_autoimport_auto_pipenv is set):
44   let g:ale_python_autoimport_auto_pipenv = 1
45
46   call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
47
48   AssertEqual
49   \ {
50   \   'cwd': '%s:h',
51   \   'command': ale#Escape('pipenv') . ' run autoimport -',
52   \ },
53   \ ale#fixers#autoimport#Fix(bufnr(''))
54
55 Execute(Poetry is detected when python_autoimport_auto_poetry is set):
56   let g:ale_python_autoimport_auto_poetry = 1
57
58   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
59
60   AssertEqual
61   \ {
62   \   'cwd': '%s:h',
63   \   'command': ale#Escape('poetry') . ' run autoimport -',
64   \ },
65   \ ale#fixers#autoimport#Fix(bufnr(''))
66
67 Execute(uv is detected when python_autoimport_auto_uv is set):
68   let g:ale_python_autoimport_auto_uv = 1
69
70   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
71
72   AssertEqual
73   \ {
74   \   'cwd': '%s:h',
75   \   'command': ale#Escape('uv') . ' run autoimport -',
76   \ },
77   \ ale#fixers#autoimport#Fix(bufnr(''))