unitests don't run under pdb

A

Amit Gupta

Hi

I have a unitest file: If I do

python testname.py : the unitests runs as usual and I get the
following results:
----------------------------------------------------------------------
Ran 2 tests in 0.024s

OK
--------------------------------------------------------------------

However, if I do "python -m pdb testnames.py": I get
ython -m pdb testnames.py
/s/nd6/amit/pyiglu/testnames.py(1)<module>()
-> import unittest
(Pdb) c

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
-------------------------------------------------------------------



Anything else, I should be doing (python version 2.5.1)


Thanks!!
 
M

Miki

Hello Amit,
python testname.py : the unitests runs as usual and I get the
following results:
----------------------------------------------------------------------
Ran 2 tests in 0.024s

OK
--------------------------------------------------------------------

However, if I do "python -m pdb testnames.py": I get
ython -m pdb testnames.py> /s/nd6/amit/pyiglu/testnames.py(1)<module>()

-> import unittest
(Pdb) c

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
-------------------------------------------------------------------
IIRC unittest checks the __main__ module for tests to run. Once you
run python with "-m pdb" the __main__ module is pdb and not your
script.

HTH,
 
A

Amit Gupta

Hello Amit,






IIRCunittestchecks the __main__ module for tests to run. Once you
run python with "-mpdb" the __main__ module ispdband not your
script.

HTH,

Ok, Sorry for late reply on this.

So What do I do, if my testcase if failing because of an uncaught
exception and I want to run it in pdb.

Thanks
 
G

Gabriel Genellina

So What do I do, if my testcase if failing because of an uncaught
exception and I want to run it in pdb.

Run your script with python -i testname.py
If an exception occur, you'll get the Python prompt. Execute:
py> import pdb
py> pdb.pm()
to enter pdb "post-mortem".
 
G

Gabriel Genellina

So What do I do, if my testcase if failing because of an uncaught
exception and I want to run it in pdb.

Oh, sorry, my last message doesn't apply because the unittest framework
caughts the exception.
Looks like you have to override TestResult.addError and call pdb.pm()
there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top