forked from pitluga/vimux-nose-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
" Backwards compatibility | ||
command! RunAllNoseTests :call RunNoseTestBuffer() | ||
command! RunFocusedNoseTests :call RunNoseTestFocued() | ||
|
||
command! RunNoseTest :call _run_nosetests("") | ||
command! RunNoseTestBuffer :call RunNoseTestBuffer() | ||
command! RunNoseTestFocused :call RunNoseTestFocused() | ||
|
||
function! RunNoseTestBuffer() | ||
call _run_nosetests(expand("%")) | ||
endfunction | ||
|
||
function! RunNoseTestFocused() | ||
let test_class = _nose_test_search("class") | ||
let test_name = _nose_test_search("def test_") | ||
|
||
if test_class == "" || test_name == "" | ||
echoerr "Couldn't find class and test name to run focused test." | ||
return | ||
endif | ||
|
||
call _run_nosetests(expand("%") . ":" . test_class . "." . test_name) | ||
endfunction | ||
|
||
function! _nose_test_search(fragment) | ||
let line_num = search(a:fragment, "bs") | ||
if line_num > 0 | ||
'' | ||
return split(split(getline(line_num), " ")[1], "(")[0] | ||
else | ||
return "" | ||
endif | ||
endfunction | ||
|
||
function! _run_nosetests(test) | ||
call VimuxRunCommand(_virtualenv() . "nosetests " . a:test) | ||
endfunction | ||
|
||
function! _virtualenv() | ||
if exists("g:NoseVirtualenv") | ||
return g:NoseVirtualenv . " " | ||
else | ||
return "" | ||
end | ||
endfunction |