2020년 1월 22일 수요일

Python Test Code 예제


import unittest

class ArithTest(unittest.TestCase):
    def runTest(self):
        """ Test addition and succeed. """
        self.failUnless(1 + 1 == 2, one plus one fails!’)
        self.failIf(1 + 1 != 2, one plus one fails again!’)
        self.failUnlessEqual(1 + 1, 2, more trouble with one plus one!’)

def suite():
    suite = unittest.TestSuite()
    suite.addTest(ArithTest())
    return suite

if __name__ == __main__:
    runner = unittest.TextTestRunner()
    test_suite = suite()
    runner.run(test_suite)

댓글 없음:

댓글 쓰기