Skip to content

Commit

Permalink
Remove the need for the nosetest plugin to run focused tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmills committed Dec 1, 2015
1 parent a54aabc commit 991f72e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 63 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ Vimux plugin for running nose test. Similar to [vimux-ruby-test](https://github.

## Requirements

- vim with ruby support (compiled +ruby)
- vim
- [vimux](https://github.com/benmills/vimux) (0.3.0 or greater)
- optionally requires [nose-run-line-number](https://github.com/pitluga/nose-run-line-number) for focused tests.

## Installation

It's pathogen compliant, so just drop in your bundle directory

## Commands

- RunAllNoseTests - runs all the nose tests in a file
- RunFocusedNoseTests - runs the current test under the cursor (requires nose-run-line-number)
- RunNoseTest - runs all the nose tests
- RunNoseTestBuffer - runs all the nose tests in the current file
- RunNoseTestFocused - runs the current test under the cursor (requires nose-run-line-number)

## Configuration

Expand Down
59 changes: 0 additions & 59 deletions plugin/python.vim

This file was deleted.

45 changes: 45 additions & 0 deletions plugin/vimux-nose-test.vim
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

0 comments on commit 991f72e

Please sign in to comment.