dape icon indicating copy to clipboard operation
dape copied to clipboard

How to integrate dape with pytest?

Open liullo opened this issue 1 year ago • 3 comments

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.

liullo avatar Mar 02 '24 11:03 liullo

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

svaante avatar Mar 05 '24 23:03 svaante

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?

liullo avatar Mar 07 '24 14:03 liullo

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

svaante avatar Mar 07 '24 17:03 svaante

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.

johannes-mueller avatar Jun 08 '24 09:06 johannes-mueller

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"]

Peter-Chou avatar Jul 16 '24 10:07 Peter-Chou

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

svaante avatar Aug 10 '24 13:08 svaante