Django unittest error checking in pdb

I have a unittest that throws an exception. The exception does not throw my code, it is from somewhere deep inside django. I want to open a pdb session in this place and see what happens, but when I open ipython with pdb and run test myapp , test runs, throws an exception, prints it, but pdb does not break anything.

I think the desperate solution is to open the django source and insert import pdb; pdb.set_trace() import pdb; pdb.set_trace() to the place I want to explore. But there must be a better way. What am I missing?

+4
source share
2 answers

it is possible to use media to run your tests using the -pdb option.

+2
source

Why don't you put a breakpoint ( import pdb; pdb.set_trace() ) in your code and check the process? I mean, with the letter 's' you can go inside the function so you can go deep down to the Django code.

I do not know why you think that using a breakpoint, as you say, is a bad solution. Actually, this is how I debug all my code.

BTW: try ipdb insteand pdb. You will like it;)

0
source

Source: https://habr.com/ru/post/1402512/


All Articles