Python unittest.TestCase object has no attribute 'runTest'

前端 未结 4 1980
执笔经年
执笔经年 2020-12-30 22:28

For the following code:

import unittest

class Test(unittest.TestCase):
    def test1(self):
        assert(True == True)

if __name__ == \"__main__\":
    s         


        
4条回答
  •  一生所求
    2020-12-30 23:15

    You need to invoke a TestLoader:

    if __name__ == "__main__":
        suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
        unittest.TextTestRunner().run(suite)
    

提交回复
热议问题