summaryrefslogtreecommitdiff
path: root/gitlab/tests
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-04-07 10:41:17 +0200
committerGitHub <noreply@github.com>2020-04-07 10:41:17 +0200
commit6749859505db73655f13a7950e70b67c1ee1d0fb (patch)
treee5342d52dc7c7dfbdaf2ed14b79c9d28a147ac30 /gitlab/tests
parent5979750fcc953148fcca910c04258f56c3027bce (diff)
parent79fef262c3e05ff626981c891d9377abb1e18533 (diff)
downloadgitlab-6749859505db73655f13a7950e70b67c1ee1d0fb.tar.gz
Merge pull request #1059 from python-gitlab/fix/raise-from
chore: use raise..from for chained exceptions (#939)
Diffstat (limited to 'gitlab/tests')
-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)