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.
2 call ale#assert#SetUpFixerTest('python', 'black')
5 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
8 call ale#assert#TearDownFixerTest()
13 Execute(The black callback should return the correct default values):
14 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
15 silent execute 'file ' . fnameescape(file_path)
16 let fname = ale#Escape(ale#path#Simplify(file_path))
21 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --stdin-filename ' . fname . ' -'},
22 \ ale#fixers#black#Fix(bufnr(''))
24 Execute(The black callback should include options):
25 let g:ale_python_black_options = '--some-option'
26 let g:ale_python_black_change_directory = 0
28 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
29 silent execute 'file ' . fnameescape(file_path)
30 let fname = ale#Escape(ale#path#Simplify(file_path))
33 \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option --stdin-filename ' . fname . ' -'},
34 \ ale#fixers#black#Fix(bufnr(''))
36 Execute(The black callback should include --pyi for .pyi files):
37 let g:ale_python_black_change_directory = 0
39 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi'
40 silent execute 'file ' . fnameescape(file_path)
41 let fname = ale#Escape(ale#path#Simplify(file_path))
44 \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --stdin-filename ' . fname . ' --pyi -'},
45 \ ale#fixers#black#Fix(bufnr(''))
47 Execute(The black callback should not concatenate options):
48 let g:ale_python_black_options = '--some-option'
49 let g:ale_python_black_change_directory = 0
51 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi'
52 silent execute 'file ' . fnameescape(file_path)
53 let fname = ale#Escape(ale#path#Simplify(file_path))
56 \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option --stdin-filename ' . fname. ' --pyi -'},
57 \ ale#fixers#black#Fix(bufnr(''))
59 Execute(Pipenv is detected when python_black_auto_pipenv is set):
60 let g:ale_python_black_auto_pipenv = 1
61 let g:ale_python_black_change_directory = 0
63 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
65 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/pipenv/whatever.py'))
68 \ {'command': ale#Escape('pipenv') . ' run black --stdin-filename '.fname.' -'},
69 \ ale#fixers#black#Fix(bufnr(''))
71 Execute(Poetry is detected when python_black_auto_poetry is set):
72 let g:ale_python_black_auto_poetry = 1
73 let g:ale_python_black_change_directory = 0
75 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
77 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
80 \ {'command': ale#Escape('poetry') . ' run black --stdin-filename '.fname.' -'},
81 \ ale#fixers#black#Fix(bufnr(''))
83 Execute(uv is detected when python_black_auto_uv is set):
84 let g:ale_python_black_auto_uv = 1
85 let g:ale_python_black_change_directory = 0
87 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
89 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
92 \ {'command': ale#Escape('uv') . ' run black --stdin-filename '.fname.' -'},
93 \ ale#fixers#black#Fix(bufnr(''))