[TIP] Nose questions

Nat Williams nwilliams at leapfrogonline.com
Fri Sep 5 07:13:58 PDT 2008


On 9/5/08 6:55 AM, "Toby White" <toby.o.h.white at googlemail.com> wrote:

> (apologies if there is a better, more nose-specific place to send
> questions, but I couldn't find one)

http://groups.google.com/group/nose-users is a good place

>
> I've recently started with nose, which is mostly fine so far, but I've
> two questions on its use - I'd be grateful for any pointers.
>
>
> 1) How do I use nose, doctests & pdb together. The docs seem to
> suggest ought to be possible, but I can't work out how.
> If I put the standard "import pdb;pdb.set_trace()" in my doctests, and
> run them through nose, all that happens is that nose hangs; Ctrl-C-ing
> it reveals that it's waiting inside pdb for input, but nose has
> presumably done something with stdin/stdout
>
> $ nosetests -vv --with-doctest nullNugget.py
> Doctest: nullNugget.Nugget ... ^CTraceback (most recent call last):
>   File "/usr/local/bin/nosetests", line 8, in <module>
>     load_entry_point('nose==0.10.3', 'console_scripts', 'nosetests')()
> [...]
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/doctest.py", line 328, in trace_dispatch
>     return pdb.Pdb.trace_dispatch(self, *args)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/bdb.py", line 52, in trace_dispatch
>     return self.dispatch_return(frame, arg)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/bdb.py", line 85, in dispatch_return
>     self.user_return(frame, arg)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/pdb.py", line 170, in user_return
>     self.interaction(frame, None)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/pdb.py", line 187, in interaction
>     self.cmdloop()
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/cmd.py", line 136, in cmdloop
>     line = self.stdin.readline()
> KeyboardInterrupt
>

Run nosetests with the -s option to disable the capture plugin.  That will
let you see and interact with pdb.

>
>
> 2) Can I use attribute selectors with doctests?

Are you putting doctests in the test functions themselves?  I'm fairly sure
that's discouraged, or otherwise not a good idea.  As I understand it,
doctests are for the libraries and other modules that your tests use, not
the tests themselves.
>
>
> Toby
>

Nat


CONFIDENTIALITY NOTE
The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.


More information about the testing-in-python mailing list