UnitTest 관련 자료

정은경·2020년 3월 31일
0

self.assertRaises()

import unittest
from my_merge_request import MergeRequestStatus, MergeRequestException, MergeRequest


class TestMergeRequestStatus(unittest.TestCase):

    def test_cannot_up_vote_on_closed_merge_request(self):
        merge_request = MergeRequest()
        merge_request.close()
        self.assertRaises(
            MergeRequestException,
            merge_request.up_vote,
            "dev1",
        )

self.assertRaiseRegex()

import unittest
from my_merge_request import MergeRequestStatus, MergeRequestException, MergeRequest



    def test_cannot_down_vote_on_closed_merge_request(self):
        merge_request = MergeRequest()
        merge_request.close()
        self.assertRaisesRegex(
            Exception,
            r"종료된 머지 리퀘스트에 투표할 수 없음",
            merge_request.down_vote,
            "dev1"
        )

Reference

profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글