잠토의 잠망경

[python] unitest 본문

카테고리 없음

[python] unitest

잠수함토끼 2020. 6. 13. 08:17

참고

pycharm에서는 실행에 unitest 부분이 있다.
이걸로 실행한다.

sample code


def add(a, c):
    return a+c


def mul(a, c):
    return a*c


def divided(a, c):
    return a/c

test code

github

import unittest
import sample.myCalc as myCalc


class myCalcTest(unittest.TestCase):

    def test_add(self):
        c = myCalc.add(10, 30)

        self.assertEqual(c, 40)

    def test_mul(self):
        c = myCalc.mul(10, 30)

        self.assertEqual(c, 300)

    def test_divided(self):
        c = myCalc.divided(10, 30)

        self.assertEqual(c, 0)


if __name__ == '__main__':
    unittest.main()
Comments