" copied to clipboard ("*) register.
function! python#testname#get() abort
- normal mm
- normal ?.*\s*def .*[Tt]est\r
- normal ^f(Byw
- let postfix = @"
- normal [[f(Byw
- let postfix = @" . "." . postfix
- normal `m
- let base = join([""] + split(getcwd(), "/")[:-1], "/")
- let prefix = substitute(expand("%:p:r")[len(base)+1:], "/", ".", "g")
- let name = prefix . ":" . postfix
- let @* = name
- echomsg name
+ let l:pos = getpos(".")
+ let l:postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[:-2]
+ let l:postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[:-2] . "." . l:postfix
+ call setpos(".", l:pos)
+ let l:base = join([""] + split(getcwd(), "/")[:-1], "/")
+ let l:prefix = substitute(expand("%:p:r")[len(l:base)+1:], "/", ".", "g")
+ let l:name = l:prefix . ":" . l:postfix
+ let @* = l:name
+ echomsg l:name
endfunction