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

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / fixers / test_black_fixer_callback.vader
1 Before:
2   call ale#assert#SetUpFixerTest('python', 'black')
3
4   let g:dir = getcwd()
5   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
6
7 After:
8   call ale#assert#TearDownFixerTest()
9
10   unlet! g:dir
11   unlet! b:bin_dir
12
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))
17   
18   AssertEqual
19   \ {
20   \   'cwd': '%s:h',
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(''))
23
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
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   
32   AssertEqual
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(''))
35
36 Execute(The black callback should include --pyi for .pyi files):
37   let g:ale_python_black_change_directory = 0
38
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))
42
43   AssertEqual
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(''))
46
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
50
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))
54
55   AssertEqual
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(''))
58
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
62
63   call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
64
65   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/pipenv/whatever.py'))
66
67   AssertEqual
68   \ {'command': ale#Escape('pipenv') . ' run black --stdin-filename '.fname.' -'},
69   \ ale#fixers#black#Fix(bufnr(''))
70
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
74
75   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
76
77   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
78
79   AssertEqual
80   \ {'command': ale#Escape('poetry') . ' run black --stdin-filename '.fname.' -'},
81   \ ale#fixers#black#Fix(bufnr(''))
82
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
86
87   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
88   
89   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
90   
91   AssertEqual
92   \ {'command': ale#Escape('uv') . ' run black --stdin-filename '.fname.' -'},
93   \ ale#fixers#black#Fix(bufnr(''))
94