diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2020-03-30 01:19:23 +0200 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2020-03-30 01:19:23 +0200 |
commit | 79fef262c3e05ff626981c891d9377abb1e18533 (patch) | |
tree | 360a2e7d0196441fff5132edaaede48c1e8fa283 /gitlab/tests/test_exceptions.py | |
parent | c5904c4c2e79ec302ff0de20bcb2792be4924bbe (diff) | |
download | gitlab-fix/raise-from.tar.gz |
chore: use raise..from for chained exceptions (#939)fix/raise-from
Diffstat (limited to 'gitlab/tests/test_exceptions.py')
-rw-r--r-- | gitlab/tests/test_exceptions.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/tests/test_exceptions.py b/gitlab/tests/test_exceptions.py new file mode 100644 index 0000000..1f00af0 --- /dev/null +++ b/gitlab/tests/test_exceptions.py @@ -0,0 +1,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) |