[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

unitests don't run under pdb

wildwest

2/20/2008 8:09:00 PM

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!!
4 Answers

Miki

2/21/2008 3:52:00 AM

0

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,
--
Miki <miki.tebeka@gmail.com>
http://pythonwise.bl...

wildwest

3/14/2008 7:23:00 PM

0

On Feb 20, 8:51 pm, Miki <miki.teb...@gmail.com> wrote:
> 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 -mpdbtestnames.py": I get
> > ython -mpdbtestnames.py> /s/nd6/amit/pyiglu/testnames.py(1)<module>()
>
> > -> importunittest
> > (Pdb) c
>
> > ----------------------------------------------------------------------
> > Ran 0 tests in 0.000s
>
> > OK
> > -------------------------------------------------------------------
>
> IIRCunittestchecks the __main__ module for tests to run. Once you
> run python with "-mpdb" the __main__ module ispdband not your
> script.
>
> HTH,
> --
> Miki <miki.teb...@gmail.com>http://pythonwise.bl...

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

Gabriel Genellina

3/15/2008 9:11:00 AM

0

En Fri, 14 Mar 2008 17:23:14 -0200, Amit Gupta <emailamit@gmail.com>
escribi�:
> On Feb 20, 8:51 pm, Miki <miki.teb...@gmail.com> wrote:
>> 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 -mpdbtestnames.py": I get
>> > ython -mpdbtestnames.py> /s/nd6/amit/pyiglu/testnames.py(1)<module>()
>>
>> > -> importunittest
>> > (Pdb) c
>>
>> > ----------------------------------------------------------------------
>> > Ran 0 tests in 0.000s
>>
>
> 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".

--
Gabriel Genellina

Gabriel Genellina

3/15/2008 9:14:00 AM

0

En Fri, 14 Mar 2008 17:23:14 -0200, Amit Gupta <emailamit@gmail.com>
escribi�:

> 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.

--
Gabriel Genellina