@@ -11,39 +11,49 @@ After:
1111 unlet! b:bin_dir
1212
1313Execute(The black callback should return the correct default values):
14- silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
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))
17+
1518 AssertEqual
1619 \ {
1720 \ 'cwd': '%s:h',
18- \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
21+ \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --stdin-filename ' . fname . ' - '},
1922 \ ale#fixers#black#Fix(bufnr(''))
2023
2124Execute(The black callback should include options):
2225 let g:ale_python_black_options = '--some-option'
2326 let g:ale_python_black_change_directory = 0
24-
25- silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
27+
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))
31+
2632 AssertEqual
27- \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option -' },
33+ \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option --stdin-filename ' . fname . ' -' },
2834 \ ale#fixers#black#Fix(bufnr(''))
2935
3036Execute(The black callback should include --pyi for .pyi files):
3137 let g:ale_python_black_change_directory = 0
3238
33- silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi')
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))
3442
3543 AssertEqual
36- \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --pyi -' },
44+ \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --stdin-filename ' . fname . ' -- pyi -'},
3745 \ ale#fixers#black#Fix(bufnr(''))
3846
3947Execute(The black callback should not concatenate options):
4048 let g:ale_python_black_options = '--some-option'
4149 let g:ale_python_black_change_directory = 0
4250
43- silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi')
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))
4454
4555 AssertEqual
46- \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option --pyi -' },
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 -'},
4757 \ ale#fixers#black#Fix(bufnr(''))
4858
4959Execute(Pipenv is detected when python_black_auto_pipenv is set):
@@ -52,8 +62,10 @@ Execute(Pipenv is detected when python_black_auto_pipenv is set):
5262
5363 call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
5464
65+ let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/pipenv/whatever.py'))
66+
5567 AssertEqual
56- \ {'command': ale#Escape('pipenv') . ' run black -'},
68+ \ {'command': ale#Escape('pipenv') . ' run black --stdin-filename '.fname.' - '},
5769 \ ale#fixers#black#Fix(bufnr(''))
5870
5971Execute(Poetry is detected when python_black_auto_poetry is set):
@@ -62,16 +74,21 @@ Execute(Poetry is detected when python_black_auto_poetry is set):
6274
6375 call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
6476
77+ let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
78+
6579 AssertEqual
66- \ {'command': ale#Escape('poetry') . ' run black -'},
80+ \ {'command': ale#Escape('poetry') . ' run black --stdin-filename '.fname.' - '},
6781 \ ale#fixers#black#Fix(bufnr(''))
6882
6983Execute(uv is detected when python_black_auto_uv is set):
7084 let g:ale_python_black_auto_uv = 1
7185 let g:ale_python_black_change_directory = 0
7286
7387 call ale#test#SetFilename('../test-files/python/uv/whatever.py')
74-
88+
89+ let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
90+
7591 AssertEqual
76- \ {'command': ale#Escape('uv') . ' run black -'},
92+ \ {'command': ale#Escape('uv') . ' run black --stdin-filename '.fname.' - '},
7793 \ ale#fixers#black#Fix(bufnr(''))
94+
0 commit comments