[qmtest] Too many questions?

Nathaniel Smith njs at pobox.com
Sat Mar 29 04:29:16 UTC 2003


On Fri, Mar 28, 2003 at 03:14:50PM -0800, John Schmitt wrote:
[...]
> I thought I had seen a message in the archives from someone who was
> debugging QMTest and had an easy way to debug it.  I couldn't find it
> recently when I did a search.  Any suggestions on how to set a
> breakpoint etc?

I suppose you might have been thinking about a message I sent a while
back that described the setup you have to use if you want to use
qmtest code without actually running the qmtest wrapper script.  I
find it useful for debugging to start an interactive python, load my
extension class in, and play with it directly, but this is a bit
tricky --- extension modules tend to import modules from the qm
namespace, but the qm files aren't, by default, put anywhere where
python can find them.  qmtest also assumes various environment
variables will be set.  Anyway, last I checked, the following works:
  >>> import sys
  >>> sys.path += "/usr/lib/qm", "/usr/lib/qm/xmlrpc", "/usr/lib/qm/zope-dtml"
  >>> import os
  >>> os.environ["QM_HOME"] = "/usr/lib/qm"
  >>> os.environ["QM_SHARE_PATH"] = "/usr/share/qm"
  >>> # now you can "import qm.label" or whatever it is you want
This is probably not quite up to date anymore (I think xmlrpc got
deleted recently, for instance, so that bit's no longer important), and
it assumes that you have qmtest installed in /usr, but may help.

If what you really want is to run qmtest itself in a debugger, then
that's a bit different.  You have a few options.  The easiest is to
stick a
  import pdb
  pdb.set_trace()
whereever you're interested; then when qmtest hits that point, it'll
break into the debugger, and you'll be able to do whatever you want.
(A variation on this simply sticks that call at the beginning of the
program, possibly conditioned on a command line option, the idea being
that instead of always finding the place where you want to break, you
just run the program and then set a breakpoint from within the
debugger.)

If you don't want to modify the source (and I wouldn't blame you!),
life gets a bit more complicated.  Looking at things, I _think_ you
could start up an interactive interpreter, run the magic setup juju
above, and then do
  >>> import pdb
  >>> sys.argv = [ "qmtest", "then", "whatever", "args", "you", "want" ]
  >>> pdb.run('execfile("/usr/lib/qm/test/qmtest.py")')
But I haven't actually tried it.

There's also various quirkiness involving the QM_BUILD environment
variable which I haven't fully examined -- it might be useful to set
it to 1, if you're trying to run in the source tree, but doing so
might change some of the other advice.  It's all a bit of a mess :-).

Hope that helps,
-- Nathaniel

-- 
"...these, like all words, have single, decontextualized meanings: everyone
knows what each of these words means, everyone knows what constitutes an
instance of each of their referents.  Language is fixed.  Meaning is
certain.  Santa Claus comes down the chimney at midnight on December 24."
  -- The Language War, Robin Lakoff

This email may be read aloud.



More information about the qmtest mailing list