473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

unitests don't run under pdb

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!!
Feb 20 '08 #1
4 1103
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 <mi*********@gmail.com>
http://pythonwise.blogspot.com
Feb 21 '08 #2
On Feb 20, 8:51 pm, Miki <miki.teb...@gmail.comwrote:
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.blogspot.com
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
Mar 14 '08 #3
En Fri, 14 Mar 2008 17:23:14 -0200, Amit Gupta <em*******@gmail.com>
escribi�:
On Feb 20, 8:51 pm, Miki <miki.teb...@gmail.comwrote:
>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:
pyimport pdb
pypdb.pm()
to enter pdb "post-mortem".

--
Gabriel Genellina

Mar 15 '08 #4
En Fri, 14 Mar 2008 17:23:14 -0200, Amit Gupta <em*******@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

Mar 15 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
16
by: mike420 | last post by:
Tayss wrote: > > app = wxPySimpleApp() > frame = MainWindow(None, -1, "A window") > frame.Show(True) > app.MainLoop() > Why do you need a macro for that? Why don't you just write
0
by: DP | last post by:
(2nd post, I think my first may have been to the wrong group - sorry) Hello Perl-ers - I´m hoping I can get some help here, because I'm very lost. Don't know Perl, I'm not a programmer. And...
28
by: DFS | last post by:
I'm unfortunately about to change, or sever, a two-year relationship with a very slow-paying client. Most of the 15 invoices I've sent them arrive 6 to 8 weeks late, and usually only after...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
21
by: jehugaleahsa | last post by:
Hello: I had an hour-long discussion with my boss today. Last night, right before I dozed off, I realized some of his code resulted in duplicate processing. I tried to explain it to him and he...
1
Nepomuk
by: Nepomuk | last post by:
You might have heard about Linux, but you don't know what it is? Or you know a few things about it, but they terrify you? Well, then this article is for you. Don't be afraid - Everyone can use Linux!...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.