alfredodeza / pytest.vim

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

Add support for pytest-pudb #70

Closed tuxxy closed 4 years ago

tuxxy commented 5 years ago

Hi, I love the plugin and just wanted to make a feature request that would make life 100x easier using this for me.

With pytest-pudb, it allows you to drop into a pudb debugger when a failure is hit by passing in --pudb (e.g: pytest test_foobar.py --pudb). What makes pudb special is all the advanced features it has that makes debugging a breeze. Give it a try if you haven't. You can examine the stack and whatnot, it's all I use now.

With that said, I'd really like to be able to call the pytest plugin and have it do the exact same thing it does with --pdb except drop me into pudb. Is that possible?

alfredodeza commented 5 years ago

It is possible to use any debugger you want already by adding a debugger line to where you want to start the debugging session and passing the -s flag to signal no capture in py.test

If that is insufficient because you need to trigger pudb on failure, you can pass any extra flags with the plugin. I see this wasn't documented properly, I will follow up on that. To pass extra flags you can do the following:

:Pytest method --pudb

Any Python object should work (not just method). Can you try that out and tell me if it works for you?

tuxxy commented 5 years ago

I did actually try that to see if it would naively work, but it appears to get stuck somehow.

When I do that, it just says py.test ==> Running tests for entire file and never stops. However, when I do pass in --pdb, it works right away.

alfredodeza commented 5 years ago

Unfortunately, seems like pytest-pudb is grabbing stdin/stdout/stderr in such a way that seems impossible to make it work with Vim and how we "drop to a terminal". It is like a curses-like implementation which I don't know how to provide access to.

What does seem to work is to use:

        import pudb; pudb.set_trace()

And then call:

:Pytest method -s
tuxxy commented 5 years ago

Hmmm...

Thanks for looking into this. I'll stick with -s for now.

alfredodeza commented 4 years ago

Since I don't know how to provide an interface to a courses-based interface and you have a workaround I am going to close this issue. Thanks for reporting it!