]> Sergey Matveev's repositories - dotfiles.git/blob - vim/.vim/ftplugin/python/testname.vim
Initial
[dotfiles.git] / vim / .vim / ftplugin / python / testname.vim
1 " Nose-compatible test name preparer
2 " Maintainer: Sergey Matveev <stargrave@stargrave.org>
3 " License: GNU General Public License version 3 of the License or later
4 "
5 " When standing inside TestCase's test method, type <leader>t and full
6 " Python (your.project.tests:TestCaseName.test_method_name) path will be
7 " copied to clipboard ("*) register.
8
9 function! TestName()
10     normal mm
11     normal ?.*\s*def .*[Tt]est\r
12     normal ^f(Byw
13     let postfix = @"
14     normal [[f(Byw
15     let postfix = @" . "." . postfix
16     normal `m
17     let base = join([""] + split(getcwd(), "/")[:-1], "/")
18     let prefix = substitute(expand("%:p:r")[len(base)+1:], "/", ".", "g")
19     let name = prefix . ":" . postfix
20     let @* = name
21     echomsg name
22 endfunction
23
24 nmap <leader>t :call TestName()<CR>