让单元测试与适用于 Python 的 Komodo IDE 一起使用
我尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于要选取的测试文件,文件名必须以
test_
开头。我尝试仅使用test.py
但失败了,但是test_.py
却像做梦一样工作。您所需要做的就是重命名您的文件。文档中对此并没有说得很清楚 - 我通过 Komodo 网站上的 错误报告解决了这个问题网站。
如果科莫多至少能提供解决该问题的线索,那就太好了!
For the test file to be picked up the filename must start with
test_
. I tried using justtest.py
which failed, howevertest_.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!