如何在 IronPython 中使用鼻子?
我在命令行上使用“setup.py install”安装了nose,我能够运行“nosetests”,并且任何与testMatch正则表达式匹配的python文件都会被拾取,并且测试会在%python home%\Scripts目录中自动进行。现在我想让鼻子与我的 Iron Python 文件一起工作,如何在 %Iron Python home% 目录上安装鼻子?我注意到我的 Iron Python 主目录甚至没有 Scripts 文件夹。 如果我尝试使用 Iron Python 代码运行“nosetests”,它会抛出各种异常 例如。没有名为 clr 的模块。
有人用铁蟒鼻子吗?如果是,请指导我。我一整天都在为此苦苦挣扎 目前我唯一的解决方法是在我的 IronPython 代码中添加以下内容:
import nose
nose.main(argv=['<arguments>'])
这是在 Iron Python 文件中使用鼻子的唯一方法吗?
如果没有其他办法的话,那么我想知道nose有的几个插件怎么用?特别是覆盖率插件?我为 python2.6 安装了它,但如何使其适用于 IronPython ?
我问的原因是因为使用 python ,只需调用命令行即可轻松使用插件,但使用 IronPython 我不知道如何使其工作。
I installed nose using the 'setup.py install' on the command line , I am able to run 'nosetests' and any python file matching testMatch regular expression is picked up and tests are automated in the %python home%\Scripts directory. Now I want nose to work with my iron Python files , how do I install nose on the %Iron Python home% directory ? i noticed my Iron Python Home directory does not even have a Scripts folder.
If i try running 'nosetests' with iron python code , it throws all sorts of exception
for eg. no module named clr.
Is anybody using nose with iron python ? if yes , please guide me. I have been struggling with this since an entire day,
currently my only workaround has been adding the following in my IronPython code:
import nose
nose.main(argv=['<arguments>'])
is this is the only way to go about using nose in iron python files ?
if there is no other way , then I wanted to know how to use the several plugins that nose has ? especially the coverage plugin ? i installed it for python2.6 , but how to make it work for ironpython ?
The reason I am asking is because with python , it gets easy to use the plugins just by calling the command line , but with IronPython I don't know how to make it work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的解决方案实际上是
nosetests
所做的一切:需要确保将系统的 Python 库添加到路径中,以便它找到鼻子扩展:
并且您需要确保使用
ipy.exe
执行脚本,而不是您系统的 Python 可执行文件。Your solution is actually all
nosetests
does:You'll want to make sure you add your system's Python lib to the path for it to find the nose extensions:
And you'll need to make sure you're executing your script with
ipy.exe
and not your system's Python executable.我一直在尝试运行 sqlalchemy 测试套件,它使用鼻子和插件。因此,如果有人尝试使用插件在 IronPython 上运行鼻子,这可能会很有用。
这在 ipy 上往往无法透明地工作,因为 setuptools 在 IronPython 上不太工作。
经过一番挖掘,我找到了用于手动注册插件的nose init.py 指令 - 本质上是导入插件类(它是nose.plugins.Plugin的子类),并将其添加到调用中主要的()。
这就是我的脚本最终的样子:
希望这对某人有帮助!
I've been trying to run the sqlalchemy test suite, which uses nose and a plugin. So, this may be useful if anyone is trying to run nose on ironpython with plugins.
this tends not to work transparently on ipy, because setuptools doesn't quite work on ironpython.
after a bit of diggin, i found the nose init.py instructions for registering a plugin manually - essentially, import the plugin class (which subclasses nose.plugins.Plugin), and add it to the call to main().
here's what my script ended up looking like:
Hope this helps someone!