svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

How to integrate dape with pytest? #79

Closed liullo closed 1 week ago

liullo commented 5 months ago

I've searched the web, and can not find a solution to integrate dape with pytest. Can anyone give me some ideas about the workflow for testing and debugging? Thanks.

svaante commented 5 months ago

Hey I just pushed an batteries included config that works great with pytest, so you need to use the latest commit for this to work.

It's called `debugpy-module', see screenshot for usage (note that "User Uncaught Exceptions" need to be enabled to break at assertion error).

debugpy-module :module "pytest"

bild

liullo commented 5 months ago

Great work! Thanks for your reply! But it did not break at any assertion error or breakpoint even when the "User Uncaught Exceptions" was enabled. What was I missing?

svaante commented 5 months ago

Would you mind share some additional information?

  1. (setq dape-debug t)
  2. Start debugpy-module :module "pytest"
  3. Share the contents of *dape-connection events* buffer
johannes-mueller commented 2 months ago

I've searched the web, and can not find a solution to integrate dape with pytest. Can anyone give me some ideas about the workflow for testing and debugging? Thanks.

Maybe take a look at test-cockpit.el which for python/pytest now supports to run the last pytest run as a dape debug session. I would like to encourage you to give it a try and give feedback.

Peter-Chou commented 1 month ago

I accidently figured out that you can use dape to debug specific test function in specific test file by simply runing this command:

debugpy-module :module "pytest" :args ["test_file_relative_path_to_base_project::test_method_name"]
svaante commented 1 week ago

Nice find @Peter-Chou added to wiki. Feel free to extend/improve wiki pytest debugging