]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_mypy.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 '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / linter / test_mypy.vader
1 Before:
2   call ale#assert#SetUpLinterTest('python', 'mypy')
3   call ale#test#SetFilename('test.py')
4
5   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
6
7 After:
8   unlet! b:bin_dir
9   unlet! b:executable
10
11   call ale#assert#TearDownLinterTest()
12
13 Execute(The mypy callbacks should return the correct default values):
14   AssertLinterCwd g:dir
15   AssertLinter 'mypy',
16   \ ale#Escape('mypy')
17   \   . ' --show-column-numbers'
18   \   . ' --shadow-file %s %t %s'
19
20 Execute(The mypy executable should be configurable, and escaped properly):
21   let g:ale_python_mypy_executable = 'executable with spaces'
22
23   AssertLinter 'executable with spaces',
24   \ ale#Escape('executable with spaces')
25   \   . ' --show-column-numbers'
26   \   . ' --shadow-file %s %t %s'
27
28 Execute(The mypy command callback should let you set options):
29   let g:ale_python_mypy_options = '--some-option'
30
31   AssertLinter 'mypy',
32   \ ale#Escape('mypy')
33   \   . ' --some-option'
34   \   . ' --show-column-numbers'
35   \   . ' --shadow-file %s %t %s'
36
37 Execute(The mypy command should switch directories to the detected project root):
38   call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
39
40   AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir')
41   AssertLinter 'mypy',
42   \   ale#Escape('mypy')
43   \   . ' --show-column-numbers'
44   \   . ' --shadow-file %s %t %s'
45
46 Execute(The mypy callbacks should detect virtualenv directories and switch to the project root):
47   call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
48
49   let b:executable = ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/mypy')
50
51   AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
52   AssertLinter b:executable,
53   \ ale#Escape(b:executable)
54   \   . ' --show-column-numbers'
55   \   . ' --shadow-file %s %t %s'
56
57 Execute(The mypy callbacks should cd to directory containing mypy.ini if found):
58   call ale#test#SetFilename('../test-files/python/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py')
59
60   AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_mypy_ini_and_pytest_ini')
61   AssertLinter 'mypy',
62   \ ale#Escape('mypy')
63   \   . ' --show-column-numbers'
64   \   . ' --shadow-file %s %t %s'
65
66 Execute(You should able able to use the global mypy instead):
67   call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
68   let g:ale_python_mypy_use_global = 1
69
70   AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
71   AssertLinter 'mypy',
72   \ ale#Escape('mypy')
73   \   . ' --show-column-numbers'
74   \   . ' --shadow-file %s %t %s'
75
76 Execute(Setting executable to 'pipenv' appends 'run mypy'):
77   let g:ale_python_mypy_executable = 'path/to/pipenv'
78
79   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
80   AssertLinter 'path/to/pipenv',
81   \ ale#Escape('path/to/pipenv') . ' run mypy'
82   \   . ' --show-column-numbers --shadow-file %s %t %s'
83
84 Execute(Pipenv is detected when python_mypy_auto_pipenv is set):
85   call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
86   let g:ale_python_mypy_auto_pipenv = 1
87
88   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
89   AssertLinter 'pipenv',
90   \ ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'
91
92 Execute(Setting executable to 'poetry' appends 'run mypy'):
93   let g:ale_python_mypy_executable = 'path/to/poetry'
94
95   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
96   AssertLinter 'path/to/poetry',
97   \ ale#Escape('path/to/poetry') . ' run mypy'
98   \   . ' --show-column-numbers --shadow-file %s %t %s'
99
100 Execute(Poetry is detected when python_mypy_auto_poetry is set):
101   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
102   let g:ale_python_mypy_auto_poetry = 1
103
104   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
105   AssertLinter 'poetry',
106   \ ale#Escape('poetry') . ' run mypy --show-column-numbers --shadow-file %s %t %s'
107
108 Execute(uv is detected when python_mypy_auto_uv is set):
109   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
110   let g:ale_python_mypy_auto_uv = 1
111
112   AssertLinterCwd expand('#' . bufnr('') . ':p:h')
113   AssertLinter 'uv',
114   \ ale#Escape('uv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'