简体   繁体   中英

Getting Unit Tests to work with Komodo IDE for Python

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM