summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_exceptions.py
blob: 1f00af067c22e43df782a01b4860eb0ec1e8cd7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import unittest

from gitlab import exceptions


class TestExceptions(unittest.TestCase):
    def test_error_raises_from_http_error(self):
        """Methods decorated with @on_http_error should raise from GitlabHttpError."""

        class TestError(Exception):
            pass

        @exceptions.on_http_error(TestError)
        def raise_error_from_http_error():
            raise exceptions.GitlabHttpError

        with self.assertRaises(TestError) as context:
            raise_error_from_http_error()
        self.assertIsInstance(context.exception.__cause__, exceptions.GitlabHttpError)