IronPython 用于使用 IronPython Studios 进行单元测试
我想尝试一下 IronPython,并认为编写单元测试是一种足够简单的入门方法。 这本质上意味着我的核心应用程序代码仍将用 C# 编写,只有我的测试是 python。
考虑到这一点,我的理想情况是在 Visual Studio 中的同一解决方案中开发 C# 和 IronPython 代码。 环顾四周,我发现有一个视觉工作室编辑器“IronPythonStudios”应该适合我,尽管到目前为止我遇到了一些问题:
- 导入核心Python库(例如“Import os”)失败。 我相信这是因为这些公共库的路径没有在 IDE 中设置,我不知道如何设置它。
- 我无法识别来自 Visual Studio 的 .pyproj 文件,我相信我的 IronPythonStudios 版本在隔离模式下运行且未集成。 知道我如何改变这个吗?
- 看来 IronPythonStudos 正在编译 .py 文件,而不仅仅是解释它们。 这本质上意味着单元测试与 C#/Vb.net 一样慢,因为测试、构建然后执行循环仍然存在。 知道如何阻止 VS/IPS 编译文件并让它动态编译脚本吗?
干杯,克里斯。
Im looking to play with IronPython and figured that writing unit tests is a simple enough way to get started. This would essentially mean that my core applications code will still be written in C# with just my tests been python.
With this in mind my ideal situation was to develop both the C# and IronPython code from within the same solution in Visual studios. Looking around I see that there is a visual studios editor "IronPythonStudios" that should be right for me, though so far I have hit a few issues:
- Importing core python libaries such as "Import os" fail. I believe this is because the path to these common libaries is not set within the IDE and I have no idea how to set it.
- I am unable to recognize .pyproj files from visual studios, I believe that my version of IronPythonStudios is running in Isolated mode and not integrated. Any idea how I change this?
- It appears that IronPythonStudos is compiling the .py files instead of just interpreting them. This essentailly means that unit testing is as slow as with C#/Vb.net as the test, build then exectue cycle still exists. Any idea how I stop VS/IPS from compiling the files and just get it to just dynamically compile the scripts?
Cheers, Chris.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也一直在尝试将 IronPython 和 Visual Studio 集成。 您可以通过下载 Visual Studio SDK 并按照 此处。 唯一的问题是集成是针对 IPy v 1.x 而不是 2.* 构建的。 不知道这对你有多大帮助。
I also have been trying to get IronPython and Visual Studio integrated. You can do it by downloading the Visual Studio SDK and following the steps listed here. The only issue with it is that the integration is built against IPy v 1.x and not 2.*. Don't know how much of help this is to you.
如果有人想知道,为了回答我的问题的第一部分,我发现我需要添加对 Python 系统路径的引用,即
编辑:
还值得注意的是,我下载了独立的且未集成的 IronPython studio 发行版,这是我的第一个问题。
In case anyone was wondering, to answer the first part of my question I found that I needed to add a reference to Pythons sys path i.e.
EDIT:
Its also worth noting that I downloaded the isolated and not intergrated IronPython studio distribution which was my first problem.
您可以使用 ipy 2.6 并在 eclipse 中使用 pydev 插件和代码。 很抱歉我要求您切换 IDE(我知道这有时会多么痛苦),但我使用过很多 IDE,包括 Visual Studio 和 Eclipse 我已经讨论过这个 这里,我发现 eclipse 是迄今为止我用过的最好的 IDE。 另外,eclipse 中有一个用于 C# 编程的插件,所以我强烈建议您切换。
使用 eclipse 的 pydev 插件的有趣之处在于,您不会遇到您所描述的导入问题。 此外,编译/解释问题也得到解决。
You could use ipy 2.6 and use the pydev plugin and code in eclipse. I'm sorry that I'm asking you to switch your IDE (I know how painful that can sometimes be), but I have used quite a few IDEs including Visual Studio and Eclipse I have discussed this here and I find eclipse to be the best IDE that I've used so far. Also, there is a plugin for C# programming in eclipse, so I would STRONGLY recommend you switch.
The interesting thing about using the pydev plugin for eclipse is that you will not face the import issues that you described. Also, the compile/interpret problem is also solved.