diff --git a/README.rst b/README.rst index 7a2c78d..31581c9 100755 --- a/README.rst +++ b/README.rst @@ -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 ------- diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim index 3be37cd..26e77f6 100755 --- a/ftplugin/python/pytest.vim +++ b/ftplugin/python/pytest.vim @@ -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 @@ -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