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

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / fixers / test_ruff_format_fixer_callback.vader
1 Before:
2   call ale#assert#SetUpFixerTest('python', 'ruff_format')
3
4   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
5
6 After:
7   call ale#assert#TearDownFixerTest()
8
9   unlet! g:dir
10   unlet! b:bin_dir
11
12 Execute(The ruff callback should not change directory if the option is set to 0):
13   let g:ale_python_ruff_format_change_directory = 0
14
15   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
16
17   silent execute 'file ' . fnameescape(file_path)
18
19   let fname = ale#Escape(ale#path#Simplify(file_path))
20
21   AssertFixer
22   \ {
23   \   'cwd': '%s:h',
24   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' format --stdin-filename ' . fname . ' -',
25   \ }
26
27 Execute(The ruff callback should respect custom options):
28   let g:ale_python_ruff_format_options = '--ignore F401 -q'
29
30   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
31
32   silent execute 'file ' . fnameescape(file_path)
33
34   let fname = ale#Escape(ale#path#Simplify(file_path))
35
36   AssertFixer
37   \ {
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'))
40   \     . ' format --ignore F401 -q --stdin-filename '. fname . ' -',
41   \ }
42
43 Execute(Pipenv is detected when python_ruff_format_auto_pipenv is set):
44   let g:ale_python_ruff_format_auto_pipenv = 1
45   let g:ale_python_ruff_format_change_directory = 0
46
47   let file_path = '../test-files/python/pipenv/whatever.py'
48
49   call ale#test#SetFilename(file_path)
50
51   let fname = ale#Escape(ale#path#Simplify(g:dir . '/'. file_path))
52
53   AssertFixer
54   \ {
55   \   'cwd': '%s:h',
56   \   'command': ale#Escape('pipenv') . ' run ruff format --stdin-filename ' . fname . ' -'
57   \ }
58
59 Execute(Poetry is detected when python_ruff_auto_poetry is set):
60   let g:ale_python_ruff_format_auto_poetry = 1
61   let g:ale_python_ruff_format_change_directory = 0
62
63   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
64
65   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
66
67   AssertFixer
68   \ {
69   \   'cwd': '%s:h',
70   \   'command': ale#Escape('poetry') . ' run ruff format --stdin-filename ' . fname . ' -'
71   \ }
72
73 Execute(Poetry is detected when python_ruff_format_auto_poetry is set, and cwd respects change_directory option):
74   let g:ale_python_ruff_format_auto_poetry = 1
75   let g:ale_python_ruff_format_change_directory = 1
76
77   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
78
79   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
80
81   AssertFixer
82   \ {
83   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/poetry'),
84   \   'command': ale#Escape('poetry') . ' run ruff format --stdin-filename ' . fname . ' -'
85   \ }
86
87 Execute(uv is detected when python_ruff_format_auto_uv is set):
88   let g:ale_python_ruff_format_auto_uv = 1
89   let g:ale_python_ruff_format_change_directory = 0
90
91   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
92
93   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
94
95   AssertFixer
96   \ {
97   \   'cwd': '%s:h',
98   \   'command': ale#Escape('uv') . ' run ruff format --stdin-filename ' . fname . ' -'
99   \ }