python unittest 只跑某个(某些)测试

# -*- coding: utf-8 -*- 

import unittest

class MyTest(unittest.TestCase):

   
    def test_method_a(self):
    	pass

    def test_method_b(self):
    	pass

    def test_method_c(self):
    	pass

if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(MyTest('test_method_a'))
    suite.addTest(MyTest('test_method_b'))

    #suite =  unittest.TestLoader().loadTestsFromTestCase(MyTest)
    unittest.TextTestRunner(verbosity=2).run(suite)

 

PS 打开注释行,就可以跑全部测试

 

-end

你可能感兴趣的:(python)