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', 'ruff')
4 let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
7 call ale#assert#TearDownFixerTest()
12 Execute(The ruff callback should return the correct default values):
13 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
15 silent execute 'file ' . fnameescape(file_path)
17 let fname = ale#Escape(ale#path#Simplify(file_path))
19 " --fix does not support stdin until 0.0.72
20 GivenCommandOutput ['ruff 0.0.72']
23 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
24 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname . ' --fix -',
27 Execute(The ruff callback should not use stdin for older versions (< 0.0.72)):
28 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
30 silent execute 'file ' . fnameescape(file_path)
32 let fname = ale#Escape(ale#path#Simplify(file_path))
34 " --fix does not support stdin until 0.0.72
35 GivenCommandOutput ['ruff 0.0.71']
38 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
39 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname . ' --fix %s',
42 Execute(The ruff callback should not change directory if the option is set to 0):
43 let g:ale_python_ruff_change_directory = 0
45 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
47 silent execute 'file ' . fnameescape(file_path)
49 let fname = ale#Escape(ale#path#Simplify(file_path))
51 " --fix does not support stdin until 0.0.72
52 GivenCommandOutput ['ruff 0.0.72']
56 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname . ' --fix -',
59 Execute(The ruff callback should respect custom options):
60 let g:ale_python_ruff_options = '--ignore F401 -q'
62 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
64 silent execute 'file ' . fnameescape(file_path)
66 let fname = ale#Escape(ale#path#Simplify(file_path))
68 GivenCommandOutput ['ruff 0.0.72']
71 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
72 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff'))
73 \ . ' --ignore F401 -q --stdin-filename '. fname . ' --fix -',
76 Execute(The ruff callback should use ruff check for 0.5.0):
77 let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
79 silent execute 'file ' . fnameescape(file_path)
81 let fname = ale#Escape(ale#path#Simplify(file_path))
83 GivenCommandOutput ['ruff 0.5.0']
86 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
87 \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' check --stdin-filename ' . fname . ' --fix -',
90 Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
91 let g:ale_python_ruff_auto_pipenv = 1
92 let g:ale_python_ruff_change_directory = 0
94 let file_path = '../test-files/python/pipenv/whatever.py'
96 call ale#test#SetFilename(file_path)
98 let fname = ale#Escape(ale#path#Simplify(g:dir . '/'. file_path))
100 GivenCommandOutput ['ruff 0.0.72']
104 \ 'command': ale#Escape('pipenv') . ' run ruff --stdin-filename ' . fname . ' --fix -'
107 Execute(Poetry is detected when python_ruff_auto_poetry is set):
108 let g:ale_python_ruff_auto_poetry = 1
109 let g:ale_python_ruff_change_directory = 0
111 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
113 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
115 GivenCommandOutput ['ruff 0.0.72']
119 \ 'command': ale#Escape('poetry') . ' run ruff --stdin-filename ' . fname . ' --fix -'
122 Execute(Poetry is detected when python_ruff_auto_poetry is set, and cwd respects change_directory option):
123 let g:ale_python_ruff_auto_poetry = 1
124 let g:ale_python_ruff_change_directory = 1
126 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
128 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
130 GivenCommandOutput ['ruff 0.0.72']
133 \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/poetry'),
134 \ 'command': ale#Escape('poetry') . ' run ruff --stdin-filename ' . fname . ' --fix -'
137 Execute(uv is detected when python_ruff_auto_uv is set):
138 let g:ale_python_ruff_auto_uv = 1
139 let g:ale_python_ruff_change_directory = 0
141 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
143 let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
145 GivenCommandOutput ['ruff 0.0.72']
149 \ 'command': ale#Escape('uv') . ' run ruff --stdin-filename ' . fname . ' --fix -'