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
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.
9 function! python#testname#get() abort
10 let l:pos = getpos(".")
11 let l:postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[:-2]
12 let l:postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[:-2] . "." . l:postfix
13 call setpos(".", l:pos)
14 let l:base = join([""] + split(getcwd(), "/")[:-1], "/")
15 let l:prefix = substitute(expand("%:p:r")[len(l:base)+1:], "/", ".", "g")
16 let l:name = l:prefix . ":" . l:postfix