在PyDev中使用nosetests进行交互式调试 [英] Interactive debugging with nosetests in PyDev

查看:219
本文介绍了在PyDev中使用nosetests进行交互式调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PyDev(与Aptana)来编写和调试一个Python Pylons应用程序,我想在调试器中通过测试。



是否可以通过PyDev启动nosetests并停止在断点?

解决方案

这是我使用eclipse Pydev运行nosetests(希望这将帮助你)。



首先我创建一个python脚本,我把它放在我的包目录的根目录:

   - 包
|
| - runtest.py
|
| - ...(其他模块)

在runtest.py中我放:

 进口鼻子
nose.main()

现在我在菜单中选择运行 - >运行配置,并创建一个新的配置 Pydev Django ,我选择我的包和将runtest.py放在主模块中,接下来我转到同一个窗口小部件的参数选项卡,并将程序参数放入我的项目路径,并将不同的参数传递给脚本示例:

  / home / me / projects / src --with-doctest#运行doctests 

现在点击应用后,我可以运行此配置。



对于调试,您可以在调试模式下运行此配置,并将您的断点放在代码中的任何位置,您可以使用极好的调试小部件来执行几个操作:逐步查看vars ...



注意:doctests难过我不认为你可以把断点放在doctest中,但是你可以做的就是把你的断点放在doctest调用的函数的def中,就像你可以使用debug模式一样。 >

I'm using PyDev ( with Aptana ) to write and debug a Python Pylons app, and I'd like to step through the tests in the debugger.

Is it possible to launch nosetests through PyDev and stop at breakpoints?

解决方案

Here is what i do to run nosetests using eclipse Pydev (Hope this will help you).

first of all i create a python script and i put it in the root of my package directory :

--Package
    |
    | -- runtest.py
    |
    | -- ... (others modules) 

and in runtest.py i put:

import nose
nose.main()

now i go to in the menu Run -> Run configurations and i create a new configuration of Pydev Django i choose my package and put runtest.py in the main Module , next i go to arguments tab in the same widget and i put in Program arguments the path to my project and different arg to pass to the script example:

/home/me/projects/src --with-doctest  # Run doctests too

now after clicking on Apply i can run this configuration .

For debugging you can run this configuration in debug mode and put your break point anywhere in your code and you can use the terrific debug widget to do several action : step into, to see vars ...

N.B : for doctests sadly i don't think you can put breakpoint in the line of doctest but what you can do is to put your breakpoint in the def of the function that is called by the doctest and like that you can use the debug mode .

这篇关于在PyDev中使用nosetests进行交互式调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆