Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 34 additions & 31 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,37 +115,40 @@ Configuration
-------------
The plugin supports setting of the following variables:

+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| Variable | Description | Values | Default |
+===============================+================================================+===========================+===================================+
| ``PyUnitShowTests`` | Shows the tests. | 0 or 1 | 1 |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitCmd`` | The command to run the unit test. | any string | "nosetests -q --with-machineout" |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``ProjRootIndicators`` | List of filenames indicating the project root. | list of file names | [".git", "setup.py", "setup.cfg"] |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``ProjRootStopAtHomeDir`` | Stop the search for the project root at the | 0 or 1 | 1 |
| | user's home dir. | | |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestPrefix`` | The filename prefix to use for test files. | any string | "test\_" |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestSuffix`` | *Not implemented yet* | 0 or 1 | n/a |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitSourceRoot`` | The relative location where all source files | directory spec, or empty | "" |
| | live. | | |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsRoot`` | The relative location where all tests live. | directory spec | "tests" |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsStructure`` | Specifies how you wish to organise your tests. | flat, follow-hierarchy, | "follow-hierarchy" |
| | | side-by-side | |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsSplitWindow`` | Specifies where test files should be opened, | left, right, top, bottom, | "right" |
| | when oopened next to the source file. When set | no | |
| | to ``no``, doesn't open a new window at all, | | |
| | but reuses the current buffer. | | |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitConfirmTestCreation`` | Ask to confirm creation of new test files. | 0 or 1 | 1 |
+-------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| Variable | Description | Values | Default |
+=================================+================================================+===========================+===================================+
| ``PyUnitShowTests`` | Shows the tests. | 0 or 1 | 1 |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitCmd`` | The command to run the unit test. | any string | "nosetests -q --with-machineout" |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``ProjRootIndicators`` | List of filenames indicating the project root. | list of file names | [".git", "setup.py", "setup.cfg"] |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``ProjRootStopAtHomeDir`` | Stop the search for the project root at the | 0 or 1 | 1 |
| | user's home dir. | | |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestPrefix`` | The filename prefix to use for test files. | any string | "test\_" |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestSuffix`` | *Not implemented yet* | 0 or 1 | n/a |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitSourceRoot`` | The relative location where all source files | directory spec, or empty | "" |
| | live. | | |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsRoot`` | The relative location where all tests live. | directory spec | "tests" |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsStructure`` | Specifies how you wish to organise your tests. | flat, follow-hierarchy, | "follow-hierarchy" |
| | | side-by-side | |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitTestsSplitWindow`` | Specifies where test files should be opened, | left, right, top, bottom, | "right" |
| | when oopened next to the source file. When set | no | |
| | to ``no``, doesn't open a new window at all, | | |
| | but reuses the current buffer. | | |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitConfirmTestCreation`` | Ask to confirm creation of new test files. | 0 or 1 | 1 |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+
| ``PyUnitOpenTestFileOnFailure`` | Ask to confirm creation of new test files on | 0 or 1 | 1 |
| | test failure. | | |
+---------------------------------+------------------------------------------------+---------------------------+-----------------------------------+


Tips
Expand Down
9 changes: 8 additions & 1 deletion ftplugin/python_pyunit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ if !exists("g:PyUnitTestsSplitWindow")
" window. Takes one of the following values: top, bottom, left, right
let PyUnitTestsSplitWindow = "right"
endif
if !exists("g:PyUnitOpenTestFileOnFailure")
" Configuration for whether or not to open test file on failures
let PyUnitOpenTestFileOnFailure = 1
endif
" }}}
"

python << endpython
import vim
Expand Down Expand Up @@ -525,7 +530,9 @@ fun! PyUnitRunNose(path) " {{{
let has_errors=getqflist() != []
if has_errors
" first, open the alternate window, too
call PyUnitSwitchToCounterpart()
if g:PyUnitOpenTestFileOnFailure == 1
call PyUnitSwitchToCounterpart()
endif
execute 'belowright copen'
setlocal wrap
nnoremap <buffer> <silent> c :cclose<CR>
Expand Down
9 changes: 8 additions & 1 deletion src/base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ if !exists("g:PyUnitTestsSplitWindow")
" window. Takes one of the following values: top, bottom, left, right
let PyUnitTestsSplitWindow = "right"
endif
if !exists("g:PyUnitOpenTestFileOnFailure")
" Configuration for whether or not to open test file on failures
let PyUnitOpenTestFileOnFailure = 1
endif
" }}}
"

python << endpython
__PYTHON_SOURCE__
Expand Down Expand Up @@ -152,7 +157,9 @@ fun! PyUnitRunNose(path) " {{{
let has_errors=getqflist() != []
if has_errors
" first, open the alternate window, too
call PyUnitSwitchToCounterpart()
if g:PyUnitOpenTestFileOnFailure == 1
call PyUnitSwitchToCounterpart()
endif
execute 'belowright copen'
setlocal wrap
nnoremap <buffer> <silent> c :cclose<CR>
Expand Down