Debugging doctests
On 2/21/06, Stephan Richter <srichter@cosmos.phy.tufts.edu> wrote:
On Tuesday 21 February 2006 12:14, Lennart Regebro wrote:
(btw, through all this, I assume that Jims fix for the doctest debugging problem that he mentioned did work, and that you now can insert an import pdb;pdb.set_trace() in the middle of the doctests. Right?)
This has been fixed since ages. :-)
Ah, not in Zope 2.9 it seems. Is this expected, or an I doing something wrong? I'm running the Five tests with bin/zopectl test --dir Products/Five as usual, and having a set_trace() in the doctests behaves exactly as with the old test runner, where you have to debug though the doctest running as well, which makes it pretty useless... Hang on, I just tried it with Zope 3.2 too, and it didn't work either. What am I doing wrong? -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
On Thursday 23 February 2006 06:53, Lennart Regebro wrote:
Ah, not in Zope 2.9 it seems. Is this expected, or an I doing something wrong? I'm running the Five tests with bin/zopectl test --dir Products/Five as usual, and having a set_trace() in the doctests behaves exactly as with the old test runner, where you have to debug though the doctest running as well, which makes it pretty useless...
How do you want to use the debugger? I run the tests, if the set_trace() occurs it throws me to the prompt and all is fine. I can use the debugger as usual. There used to be an issue with the debugger not displaying anything, since doctests mess with stdout and that has been fixed. This is what Benji and I were talking about. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training
On 2/23/06, Stephan Richter <srichter@cosmos.phy.tufts.edu> wrote:
How do you want to use the debugger?
I'd like to be able to step through the tests.
I run the tests, if the set_trace() occurs it throws me to the prompt and all is fine. I can use the debugger as usual.
When I do this, I get a prompt. Pressing next returns to the running of the tests, not the next line of the test. Here is an example: >>> import pdb;pdb.set_trace() >>> gsm = zope.component.getGlobalSiteManager() >>> gsm.provideUtility(I1, ob) >>> gsm.provideUtility(I11, ob11) When I run this, my debuggning session looks like this: $ bin/zopetest --dir zope/component Running unit tests: --Return--
/opt/Zope-3.2.0/lib/python/zope/testing/doctest.py(351)set_trace()->None -> pdb.Pdb.set_trace(self) (Pdb) s --Return-- <doctest zope.component.tests.test_getAllUtilitiesRegisteredFor[4]>(1)?()->None -> import pdb;pdb.set_trace() (Pdb) s /opt/Zope-3.2.0/lib/python/zope/testing/doctest.py(1257)__run() -> self.debugger.set_continue() # ==== Example Finished ==== (Pdb) s --Call-- /opt/Zope-3.2.0/lib/python/zope/testing/doctest.py(353)set_continue() -> def set_continue(self): (Pdb) s /opt/Zope-3.2.0/lib/python/zope/testing/doctest.py(356)set_continue() -> if self.__debugger_used: (Pdb) s /opt/Zope-3.2.0/lib/python/zope/testing/doctest.py(357)set_continue() -> pdb.Pdb.set_continue(self) (Pdb) s --Call-- /usr/lib/python2.4/bdb.py(196)set_continue() -> def set_continue(self): (Pdb) s /usr/lib/python2.4/bdb.py(198)set_continue() -> self.stopframe = self.botframe (Pdb) s
As you see, I can't even step into that next line. And even if I could, the necessity of having to step through the doctestrunning would be a major pain in the ass. Here is a non-doctest exampe as comparison. This is what I want: import pdb;pdb.set_trace() sm = zapi.getSiteManager() sm.registerUtility(IDummyUtility, dummy1) sm.registerUtility(IDummyUtility, dummy2) -> sm = zapi.getSiteManager() (Pdb) n
/home/zopes/cps34/Products/Five/site/tests/test_utility.py(209)test_registeringTwiceIsConflict() -> sm.registerUtility(IDummyUtility, dummy1) (Pdb) n /home/zopes/cps34/Products/Five/site/tests/test_utility.py(210)test_registeringTwiceIsConflict() -> sm.registerUtility(IDummyUtility, dummy2) (Pdb) s --Call-- /home/zopes/cps34/Products/Five/site/localsite.py(147)registerUtility() -> def registerUtility(self, interface, utility, name=''): (Pdb)
I can't seem to be able to do this.
There used to be an issue with the debugger not displaying anything, since doctests mess with stdout and that has been fixed. This is what Benji and I were talking about.
Oh. -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
On Thursday 23 February 2006 08:13, Lennart Regebro wrote:
As you see, I can't even step into that next line. And even if I could, the necessity of having to step through the doctestrunning would be a major pain in the ass.
Ok, I have never needed this. And I can see why it does not work. Every doctest line is its own expression. I personally can live with that limitation. As I said, I have never needed this. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training
participants (2)
-
Lennart Regebro -
Stephan Richter