pseudosudo
pseudosudo

Reputation: 6590

Inspecting django unittest errors in pdb

I have a unittest that throws an exception. The exception isn't thrown by my code, it's from somewhere deep within django. I want to open a pdb session at that spot and see what's the haps, but when I open ipython with pdb and run test myapp the test runs, throws the exception, prints it, but pdb doesn't catch anything.

I guess the desperate-man's solution is to open up django's source and insert import pdb; pdb.set_trace() at the spot I want to investigate. But there's gotta be a better way. What am I missing?

Upvotes: 4

Views: 711

Answers (2)

shaunc
shaunc

Reputation: 5611

perhaps using nosetests to run your tests with the --pdb option would work.

Upvotes: 2

pyriku
pyriku

Reputation: 1291

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

I don't know why you think that using the breakpoint as you say is a bad solution. Actually, that's how I debug all my code.

BTW: Try ipdb insteand pdb. You will love it ;)

Upvotes: 0

Related Questions