PyDev 在文档测试中设置断点

发布于 2024-09-10 19:03:51 字数 373 浏览 5 评论 0原文

是否可以使用 PyDev (即 eclipse)在 doctests 中设置断点?我发现虽然我似乎能够做到这一点,但断点根本不起作用。

为了在问题中包含一些代码并澄清,假设我已经

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

在 doctest 中的 funct() 调用处设置了一个断点。我可以这样做吗?

PS:我知道我可以

>>> import pdb; pdb.set_trace()

在文档测试中有提示,但我不想插入这样的行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零時差 2024-09-17 19:03:51

我不认为你可以在字符串中设置断点。

doctest 是一个用于自动化测试的模块。如果您需要调试文档测试代码,为什么不正常运行它并验证输出,然后在知道它有效后将其放入文档字符串中?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文