سؤال

Is it possible to set breakpoints in doctests, using PyDev (i.e. eclipse)? I found that while I am seemingly able to do so, the breakpoints do not work at all.

To have some code in the question, and to clarify, say I have

def funct():
  """
  >>> funct()
  Whatever
  """
  print "Whatever"

and that I set a breakpoint at the funct() call in the doctest. Can I do that?

PS: I know I can do

>>> import pdb; pdb.set_trace()

to have a prompt in a doctest, but I would prefer not inserting such lines.

هل كانت مفيدة؟

المحلول

I don't think you can set breakpoints in strings.

doctest is a module for automated testing. If you need to debug your doctest code, why not run it normally and verify the output, then once you know it works, throw it into a docstring?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top