让单元测试与适用于 Python 的 Komodo IDE 一起使用

发布于 2024-09-02 08:07:08 字数 636 浏览 2 评论 0原文

我尝试在 Komodo IDE(对于 python)上运行以下代码:

import unittest

class MathLibraryTests(unittest.TestCase):
    def test1Plus1Equals2(self):
        self.assertEqual(1+1, 2)

然后,我创建了一个新的测试计划,指向该项目(文件)目录并尝试运行它。它似乎可以运行,但似乎没有找到任何测试。

如果我尝试使用“常规”运行命令(F7)运行以下代码,

class MathLibraryTests(unittest.TestCase):
    def testPlus1Equals2(self):
        self.assertEqual(1+1, 2)

if __name__ == "__main__":
    unittest.main()

它会起作用。我得到以下输出:

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

我可能做错了什么?

I've tried to run the following code on Komodo IDE (for python):

import unittest

class MathLibraryTests(unittest.TestCase):
    def test1Plus1Equals2(self):
        self.assertEqual(1+1, 2)

Then, I created a new test plan, pointing to this project(file) directory and tried to run it the test plan. It seems to run but it doesn't seem to find any tests.

If I try to run the following code with the "regular" run command (F7)

class MathLibraryTests(unittest.TestCase):
    def testPlus1Equals2(self):
        self.assertEqual(1+1, 2)

if __name__ == "__main__":
    unittest.main()

it works. I get the following output:

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

What might I be doing wrong?

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

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

发布评论

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

评论(1

别忘他 2024-09-09 08:07:08

对于要选取的测试文件,文件名必须以 test_ 开头。我尝试仅使用 test.py 但失败了,但是 test_.py 却像做梦一样工作。

您所需要做的就是重命名您的文件。文档中对此并没有说得很清楚 - 我通过 Komodo 网站上的 错误报告解决了这个问题网站

如果科莫多至少能提供解决该问题的线索,那就太好了!

For the test file to be picked up the filename must start with test_. I tried using just test.py which failed, however test_.py works like a dream.

All you need to do is rename your file. This is not made very clear in the documentation - I worked it out via a bug report on Komodo's web site.

It would be nice if Komodo gave at least a clue to the problem!

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