Skip to content

Add pytest_extraflags configuration option #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ By default the test file is ``tests.py``.The global variable
configures the test file to be ``/path/to/project/tests/test_myproj.py``
(assuming the default value for the project test directory)

Pytest Flags
^^^^^^^^^^^^
By default the pytest executable is run without flags. To pass extra flags the global
variable ``pytest_extraflags`` may be used, for example::

let g:pytest_extraflags = '--testmon'

will run pytest with the ``--testmon`` flag.


License
-------

Expand Down
10 changes: 8 additions & 2 deletions ftplugin/python/pytest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ function! s:SetExecutable()
endif
endfunction

function! s:SetExtraFlags()
if !exists("g:pytest_extraflags")
let g:pytest_extraflags = ""
endif
endfunction

function! s:LoopOnFail(type)

augroup pytest_loop_autocmd
Expand Down Expand Up @@ -586,9 +592,9 @@ function! s:RunPyTest(path, ...) abort
let g:pytest_last_session = ""

if (len(parametrized) && parametrized != "0")
let cmd = g:pytest_executable . " -k " . parametrized . " " . extra_flags . " --tb=short " . a:path
let cmd = g:pytest_executable . " -k " . parametrized . " " . extra_flags . " " . g:pytest_extraflags . " --tb=short " . a:path
else
let cmd = g:pytest_executable . " " . extra_flags . " --tb=short " . a:path
let cmd = g:pytest_executable . " " . extra_flags . " " . g:pytest_extraflags . " --tb=short " . a:path
endif

" NeoVim support
Expand Down