From 1bfd021e4f1a46bde7cfcd933150af62daec53f6 Mon Sep 17 00:00:00 2001 From: Marce Coll Date: Mon, 9 Jan 2023 15:28:32 +0100 Subject: [PATCH 1/5] add testmon --- ftplugin/python/pytest.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim index 3be37cd..20097a3 100755 --- a/ftplugin/python/pytest.vim +++ b/ftplugin/python/pytest.vim @@ -365,7 +365,7 @@ endfunction function! s:RunInSplitWindow(path) - let cmd = g:pytest_executable . " --tb=short " . a:path + let cmd = g:pytest_executable . " --tb=short --testmon " . a:path let command = join(map(split(cmd), 'expand(v:val)')) let winnr = bufwinnr('PytestVerbose.pytest') silent! execute winnr < 0 ? 'botright new ' . 'PytestVerbose.pytest' : winnr . 'wincmd w' From 5b38b34af65871746d7300545de6ff567625ce0c Mon Sep 17 00:00:00 2001 From: Marce Coll Date: Mon, 9 Jan 2023 15:32:13 +0100 Subject: [PATCH 2/5] yes --- ftplugin/python/pytest.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim index 20097a3..ce04dbb 100755 --- a/ftplugin/python/pytest.vim +++ b/ftplugin/python/pytest.vim @@ -567,7 +567,7 @@ endfunction function! s:RunPyTest(path, ...) abort let parametrized = 0 - let extra_flags = '' + let extra_flags = '--testmon' let job_id = get(b:, 'job_id') if !exists("g:pytest_use_async") From 28a942b7781a0f8bd229179edfe116d7d77c08d5 Mon Sep 17 00:00:00 2001 From: Marce Coll Date: Mon, 9 Jan 2023 15:37:48 +0100 Subject: [PATCH 3/5] added extra_flags config option --- ftplugin/python/pytest.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim index ce04dbb..602eafa 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 @@ -567,7 +573,7 @@ endfunction function! s:RunPyTest(path, ...) abort let parametrized = 0 - let extra_flags = '--testmon' + let extra_flags = '' let job_id = get(b:, 'job_id') if !exists("g:pytest_use_async") @@ -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 From c3a7bff780d8a59cab34301863d885dccac7e21a Mon Sep 17 00:00:00 2001 From: Marce Coll Date: Mon, 9 Jan 2023 15:39:45 +0100 Subject: [PATCH 4/5] Remove hardcoded testmon --- ftplugin/python/pytest.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim index 602eafa..26e77f6 100755 --- a/ftplugin/python/pytest.vim +++ b/ftplugin/python/pytest.vim @@ -371,7 +371,7 @@ endfunction function! s:RunInSplitWindow(path) - let cmd = g:pytest_executable . " --tb=short --testmon " . a:path + let cmd = g:pytest_executable . " --tb=short " . a:path let command = join(map(split(cmd), 'expand(v:val)')) let winnr = bufwinnr('PytestVerbose.pytest') silent! execute winnr < 0 ? 'botright new ' . 'PytestVerbose.pytest' : winnr . 'wincmd w' From 5644196007db5ec236fddc8cfdc6ed9e5487b09c Mon Sep 17 00:00:00 2001 From: Marce Coll Date: Mon, 9 Jan 2023 15:46:03 +0100 Subject: [PATCH 5/5] Updated README --- README.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -------