IronPython 用于使用 IronPython Studios 进行单元测试

发布于 2024-07-16 17:37:11 字数 570 浏览 6 评论 0原文

我想尝试一下 IronPython,并认为编写单元测试是一种足够简单的入门方法。 这本质上意味着我的核心应用程序代码仍将用 C# 编写,只有我的测试是 python。

考虑到这一点,我的理想情况是在 Visual Studio 中的同一解决方案中开发 C# 和 IronPython 代码。 环顾四周,我发现有一个视觉工作室编辑器“IronPythonStudios”应该适合我,尽管到目前为止我遇到了一些问题:

  1. 导入核心Python库(例如“Import os”)失败。 我相信这是因为这些公共库的路径没有在 IDE 中设置,我不知道如何设置它。
  2. 我无法识别来自 Visual Studio 的 .pyproj 文件,我相信我的 IronPythonStudios 版本在隔离模式下运行且未集成。 知道我如何改变这个吗?
  3. 看来 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:

  1. 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.
  2. 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?
  3. 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 技术交流群。

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

发布评论

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

评论(3

你在我安 2024-07-23 17:37:11

我也一直在尝试将 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.

薄暮涼年 2024-07-23 17:37:11

如果有人想知道,为了回答我的问题的第一部分,我发现我需要添加对 Python 系统路径的引用,即

import sys
sys.path.append(r'c:\PathToPythonCommonLibs')

编辑:

还值得注意的是,我下载了独立的且未集成的 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.

import sys
sys.path.append(r'c:\PathToPythonCommonLibs')

EDIT:

Its also worth noting that I downloaded the isolated and not intergrated IronPython studio distribution which was my first problem.

墨落画卷 2024-07-23 17:37:11

您可以使用 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.

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