unittestテストフレームワークの使用

4045 ワード

unittestの簡単な使い方
import unittest
#         ,         
"""
     ,      
"""
class TestMy(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        print("        ,     ")
    @classmethod
    def tearDownClass(cls):
        print("         ,      ")
        
    def setUp(self):
        """           ,            """
        print("this is def-setUp")
    def tearDown(self):
        """        """
        print("this is def-tearDown")
    def test_01(self):
        """       ,   test_   """
        print("       ")
    def test_02(self):
        """        ,setUp tearDown    """
        print("          ")
if __name__ == '__main__':
    unittest.main() #       unittest  。

"""
    ,    unittest      
self.assertEqual(    ,    ,msg="    ") #            。     "    "
           
"""