Skip to content

Commit

Permalink
Merge branch 'benmills-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmills committed Dec 1, 2015
2 parents 51d523a + 355b9c8 commit 1f1d47f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 37 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ Vimux plugin for running nose test. Similar to [vimux-ruby-test](https://github.

## Requirements

- 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

## Configuration

- NoseVirtualenv - the path to your virtualenv activate file e.g. ```.env/bin/actviate```
34 changes: 0 additions & 34 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 1f1d47f

Please sign in to comment.