From 11383e70f74c70e6fe8a56f18b5b170db982f402 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Thu, 9 Apr 2020 00:13:36 +0200 Subject: chore: run unittest2pytest on all unit tests --- gitlab/tests/test_exceptions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gitlab/tests/test_exceptions.py') diff --git a/gitlab/tests/test_exceptions.py b/gitlab/tests/test_exceptions.py index 1f00af0..57622c0 100644 --- a/gitlab/tests/test_exceptions.py +++ b/gitlab/tests/test_exceptions.py @@ -1,6 +1,7 @@ import unittest from gitlab import exceptions +import pytest class TestExceptions(unittest.TestCase): @@ -14,6 +15,6 @@ class TestExceptions(unittest.TestCase): def raise_error_from_http_error(): raise exceptions.GitlabHttpError - with self.assertRaises(TestError) as context: + with pytest.raises(TestError) as context: raise_error_from_http_error() - self.assertIsInstance(context.exception.__cause__, exceptions.GitlabHttpError) + assert isinstance(context.value.__cause__, exceptions.GitlabHttpError) -- cgit v1.2.1 From 76b2cadf1418e4ea2ac420ebba5a4b4f16fbd4c7 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Fri, 17 Apr 2020 02:26:28 +0200 Subject: refactor: split unit tests by GitLab API resources --- gitlab/tests/test_exceptions.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'gitlab/tests/test_exceptions.py') diff --git a/gitlab/tests/test_exceptions.py b/gitlab/tests/test_exceptions.py index 57622c0..57b394b 100644 --- a/gitlab/tests/test_exceptions.py +++ b/gitlab/tests/test_exceptions.py @@ -1,20 +1,18 @@ -import unittest +import pytest from gitlab import exceptions -import pytest -class TestExceptions(unittest.TestCase): - def test_error_raises_from_http_error(self): - """Methods decorated with @on_http_error should raise from GitlabHttpError.""" +def test_error_raises_from_http_error(): + """Methods decorated with @on_http_error should raise from GitlabHttpError.""" - class TestError(Exception): - pass + class TestError(Exception): + pass - @exceptions.on_http_error(TestError) - def raise_error_from_http_error(): - raise exceptions.GitlabHttpError + @exceptions.on_http_error(TestError) + def raise_error_from_http_error(): + raise exceptions.GitlabHttpError - with pytest.raises(TestError) as context: - raise_error_from_http_error() - assert isinstance(context.value.__cause__, exceptions.GitlabHttpError) + with pytest.raises(TestError) as context: + raise_error_from_http_error() + assert isinstance(context.value.__cause__, exceptions.GitlabHttpError) -- cgit v1.2.1