summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_exceptions.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2020-03-30 01:19:23 +0200
committerNejc Habjan <hab.nejc@gmail.com>2020-03-30 01:19:23 +0200
commit79fef262c3e05ff626981c891d9377abb1e18533 (patch)
tree360a2e7d0196441fff5132edaaede48c1e8fa283 /gitlab/tests/test_exceptions.py
parentc5904c4c2e79ec302ff0de20bcb2792be4924bbe (diff)
downloadgitlab-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.py19
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)