]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/fixers/test_pycln_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 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / test / fixers / test_pycln_fixer_callback.vader
1 Before:
2   call ale#assert#SetUpFixerTest('python', 'pycln')
3
4   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
5
6   let b:cmd_tail = ' --silence'
7 After:
8   call ale#assert#TearDownFixerTest()
9
10   unlet! g:dir
11   unlet! b:bin_dir
12
13 Execute(The pycln callback should return the correct default values):
14   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
15
16   silent execute 'file ' . fnameescape(file_path)
17
18   GivenCommandOutput ['pycln, version 1.3.0']
19   AssertFixer
20   \ {
21   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
22   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pycln')) . b:cmd_tail . ' -',
23   \ }
24
25 Execute(The pycln callback should not use stdin for older versions (< 1.3.0)):
26   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
27
28   silent execute 'file ' . fnameescape(file_path)
29
30   GivenCommandOutput ['pycln, version 1.2.99']
31   AssertFixer
32   \ {
33   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
34   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pycln')) . b:cmd_tail . ' %s',
35   \ }
36
37 Execute(The pycln callback should not change directory if the option is set to 0):
38   let g:ale_python_pycln_change_directory = 0
39
40   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
41
42   silent execute 'file ' . fnameescape(file_path)
43
44   let fname = ale#Escape(ale#path#Simplify(file_path))
45
46   GivenCommandOutput ['pycln, version 1.3.0']
47   AssertFixer
48   \ {
49   \   'cwd': '%s:h',
50   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pycln')) . b:cmd_tail . ' -',
51   \ }
52
53 Execute(The pycln callback should respect custom options):
54   let g:ale_python_pycln_options = '--expand-stars --no-gitignore'
55
56   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
57
58   silent execute 'file ' . fnameescape(file_path)
59
60   GivenCommandOutput ['pycln, version 1.3.0']
61   AssertFixer
62   \ {
63   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
64   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/pycln'))
65   \     . ' --expand-stars --no-gitignore'  . b:cmd_tail . ' -',
66   \ }
67
68 Execute(Pipenv is detected when python_pycln_auto_pipenv is set):
69   let g:ale_python_pycln_auto_pipenv = 1
70   let g:ale_python_pycln_change_directory = 0
71
72   let file_path = '../test-files/python/pipenv/whatever.py'
73
74   call ale#test#SetFilename(file_path)
75
76   GivenCommandOutput ['pycln, version 1.3.0']
77   AssertFixer
78   \ {
79   \   'cwd': '%s:h',
80   \   'command': ale#Escape('pipenv') . ' run pycln' . b:cmd_tail . ' -'
81   \ }
82
83 Execute(Poetry is detected when python_pycln_auto_poetry is set):
84   let g:ale_python_pycln_auto_poetry = 1
85   let g:ale_python_pycln_change_directory = 0
86
87   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
88
89   GivenCommandOutput ['pycln, version 1.3.0']
90   AssertFixer
91   \ {
92   \   'cwd': '%s:h',
93   \   'command': ale#Escape('poetry') . ' run pycln' . b:cmd_tail . ' -'
94   \ }
95
96 Execute(Poetry is detected when python_pycln_auto_poetry is set, and cwd respects change_directory option):
97   let g:ale_python_pycln_auto_poetry = 1
98   let g:ale_python_pycln_change_directory = 1
99
100   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
101
102   GivenCommandOutput ['pycln, version 1.3.0']
103   AssertFixer
104   \ {
105   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/poetry'),
106   \   'command': ale#Escape('poetry') . ' run pycln' . b:cmd_tail . ' -'
107   \ }
108
109 Execute(uv is detected when python_pycln_auto_uv is set):
110   let g:ale_python_pycln_auto_uv = 1
111   let g:ale_python_pycln_change_directory = 0
112
113   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
114
115   GivenCommandOutput ['pycln, version 1.3.0']
116   AssertFixer
117   \ {
118   \   'cwd': '%s:h',
119   \   'command': ale#Escape('uv') . ' run pycln' . b:cmd_tail . ' -'
120   \ }
121
122 Execute(configuration files set in _config should be supported):
123   let g:ale_python_pycln_change_directory = 0
124   let g:ale_python_pycln_config_file = ale#path#Simplify(g:dir . '/../test-files/pycln/other_config.xml')
125
126   GivenCommandOutput ['pycln, version 1.3.0']
127   AssertFixer
128   \ {
129   \   'cwd': '%s:h',
130   \   'command': ale#Escape('pycln')
131   \     . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/pycln/other_config.xml'))
132   \     . b:cmd_tail . ' -'
133   \ }
134
135 Execute(configuration file set in _options overrides _config):
136   let g:ale_python_pycln_change_directory = 0
137   let g:ale_python_pycln_config_file = '/foo.xml'
138   let g:ale_python_pycln_options = '--config /bar.xml'
139
140   GivenCommandOutput ['pycln, version 1.3.0']
141   AssertFixer
142   \ {
143   \   'cwd': '%s:h',
144   \   'command': ale#Escape('pycln') . ' --config /bar.xml' . b:cmd_tail . ' -'
145   \ }
146
147   let b:ale_python_pycln_options = '-x --config /bar.xml'
148
149   AssertFixer
150   \ {
151   \   'cwd': '%s:h',
152   \   'command': ale#Escape('pycln') . ' -x --config /bar.xml' . b:cmd_tail . ' -'
153   \ }
154