alfredodeza / pytest.vim

Runs your UnitTests with py.test displaying red/green bars and errors
274 stars 40 forks source link

Runtime arguments not sent to :Pytest project #73

Closed leblancfg closed 4 years ago

leblancfg commented 4 years ago

I have a couple slow integration tests in my test suite, that really slow it down. They are marked as such:

@pytest.mark.slow
def test_integration_...():

For most dev tasks, I skip them by running pytest . -m "not slow".

Seems like a straightforward thing to accomplish with the plug-in, but am wondering how to set it up? Is there a way to pass extra runtime arguments to Pytest? Thanks! :bowing_man:

alfredodeza commented 4 years ago

The plugin does allow extra arguments that are then passed on to pytest itself. If you are in a class that have a few of those slow tests and want to skip them then you could do this:

:Pytest class -m "not slow"

Similarly, if in a file, you could do:

:Pytest file -m "not slow"

That should work.

leblancfg commented 4 years ago

Thanks for the fast response. It does indeed seem to work for :Pytest file, but not :Pytest project. Any way you see I might be able to achieve that? Thanks!

leblancfg commented 4 years ago

The following lines would seem to make it pass those arguments... https://github.com/alfredodeza/pytest.vim/blob/847aa6f95e3e87a32fd0aa8ff8fb04653123d277/ftplugin/python/pytest.vim#L1233 but timing the call I get the same times as without the extra -m "now slow" param.

alfredodeza commented 4 years ago

Found the issue I think, can you try applying this patch?

diff --git a/ftplugin/python/pytest.vim b/ftplugin/python/pytest.vim
index d7c7224..0f4d9d6 100755
--- a/ftplugin/python/pytest.vim
+++ b/ftplugin/python/pytest.vim
@@ -1230,8 +1230,8 @@ function! s:ThisProject(verbose, ...)
         return
     endif

-    if len(a:2)
-        let extra_flags = join(a:2, ' ')
+    if len(a:3)
+        let extra_flags = join(a:3, ' ')
     endif

     if ((a:1 == '--pdb') || (a:1 == '-s'))
leblancfg commented 4 years ago

Sure does, thanks a million! :)

alfredodeza commented 4 years ago

I'll make the update to master and then close this issue. Thank you for reporting it!