diff options
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 444 |
1 files changed, 251 insertions, 193 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index fddd5ed..c2b372a 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -21,6 +21,7 @@ from __future__ import print_function import os import pickle import tempfile + try: import unittest except ImportError: @@ -64,42 +65,52 @@ class TestSanitize(unittest.TestCase): class TestGitlabList(unittest.TestCase): def setUp(self): - self.gl = Gitlab("http://localhost", private_token="private_token", - api_version=4) + self.gl = Gitlab( + "http://localhost", private_token="private_token", api_version=4 + ) def test_build_list(self): - @urlmatch(scheme='http', netloc="localhost", path="/api/v4/tests", - method="get") + @urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests", method="get") def resp_1(url, request): - headers = {'content-type': 'application/json', - 'X-Page': 1, - 'X-Next-Page': 2, - 'X-Per-Page': 1, - 'X-Total-Pages': 2, - 'X-Total': 2, - 'Link': ( - '<http://localhost/api/v4/tests?per_page=1&page=2>;' - ' rel="next"')} + headers = { + "content-type": "application/json", + "X-Page": 1, + "X-Next-Page": 2, + "X-Per-Page": 1, + "X-Total-Pages": 2, + "X-Total": 2, + "Link": ( + "<http://localhost/api/v4/tests?per_page=1&page=2>;" ' rel="next"' + ), + } content = '[{"a": "b"}]' return response(200, content, headers, None, 5, request) - @urlmatch(scheme='http', netloc="localhost", path="/api/v4/tests", - method='get', query=r'.*page=2') + @urlmatch( + scheme="http", + netloc="localhost", + path="/api/v4/tests", + method="get", + query=r".*page=2", + ) def resp_2(url, request): - headers = {'content-type': 'application/json', - 'X-Page': 2, - 'X-Next-Page': 2, - 'X-Per-Page': 1, - 'X-Total-Pages': 2, - 'X-Total': 2} + headers = { + "content-type": "application/json", + "X-Page": 2, + "X-Next-Page": 2, + "X-Per-Page": 1, + "X-Total-Pages": 2, + "X-Total": 2, + } content = '[{"c": "d"}]' return response(200, content, headers, None, 5, request) with HTTMock(resp_1): - obj = self.gl.http_list('/tests', as_list=False) + obj = self.gl.http_list("/tests", as_list=False) self.assertEqual(len(obj), 2) - self.assertEqual(obj._next_url, - 'http://localhost/api/v4/tests?per_page=1&page=2') + self.assertEqual( + obj._next_url, "http://localhost/api/v4/tests?per_page=1&page=2" + ) self.assertEqual(obj.current_page, 1) self.assertEqual(obj.prev_page, None) self.assertEqual(obj.next_page, 2) @@ -110,306 +121,343 @@ class TestGitlabList(unittest.TestCase): with HTTMock(resp_2): l = list(obj) self.assertEqual(len(l), 2) - self.assertEqual(l[0]['a'], 'b') - self.assertEqual(l[1]['c'], 'd') + self.assertEqual(l[0]["a"], "b") + self.assertEqual(l[1]["c"], "d") class TestGitlabHttpMethods(unittest.TestCase): def setUp(self): - self.gl = Gitlab("http://localhost", private_token="private_token", - api_version=4) + self.gl = Gitlab( + "http://localhost", private_token="private_token", api_version=4 + ) def test_build_url(self): - r = self.gl._build_url('http://localhost/api/v4') - self.assertEqual(r, 'http://localhost/api/v4') - r = self.gl._build_url('https://localhost/api/v4') - self.assertEqual(r, 'https://localhost/api/v4') - r = self.gl._build_url('/projects') - self.assertEqual(r, 'http://localhost/api/v4/projects') + r = self.gl._build_url("http://localhost/api/v4") + self.assertEqual(r, "http://localhost/api/v4") + r = self.gl._build_url("https://localhost/api/v4") + self.assertEqual(r, "https://localhost/api/v4") + r = self.gl._build_url("/projects") + self.assertEqual(r, "http://localhost/api/v4/projects") def test_http_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '[{"name": "project1"}]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - http_r = self.gl.http_request('get', '/projects') + http_r = self.gl.http_request("get", "/projects") http_r.json() self.assertEqual(http_r.status_code, 200) def test_http_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="get" + ) def resp_cont(url, request): - content = {'Here is wh it failed'} + content = {"Here is wh it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, - self.gl.http_request, - 'get', '/not_there') + self.assertRaises( + GitlabHttpError, self.gl.http_request, "get", "/not_there" + ) def test_get_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"name": "project1"}' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_get('/projects') + result = self.gl.http_get("/projects") self.assertIsInstance(result, dict) - self.assertEqual(result['name'], 'project1') + self.assertEqual(result["name"], "project1") def test_get_request_raw(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/octet-stream'} - content = 'content' + headers = {"content-type": "application/octet-stream"} + content = "content" return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_get('/projects') - self.assertEqual(result.content.decode('utf-8'), 'content') + result = self.gl.http_get("/projects") + self.assertEqual(result.content.decode("utf-8"), "content") def test_get_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="get" + ) def resp_cont(url, request): - content = {'Here is wh it failed'} + content = {"Here is wh it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, self.gl.http_get, '/not_there') + self.assertRaises(GitlabHttpError, self.gl.http_get, "/not_there") def test_get_request_invalid_data(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '["name": "project1"]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabParsingError, self.gl.http_get, - '/projects') + self.assertRaises(GitlabParsingError, self.gl.http_get, "/projects") def test_list_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json', 'X-Total': 1} + headers = {"content-type": "application/json", "X-Total": 1} content = '[{"name": "project1"}]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_list('/projects', as_list=True) + result = self.gl.http_list("/projects", as_list=True) self.assertIsInstance(result, list) self.assertEqual(len(result), 1) with HTTMock(resp_cont): - result = self.gl.http_list('/projects', as_list=False) + result = self.gl.http_list("/projects", as_list=False) self.assertIsInstance(result, GitlabList) self.assertEqual(len(result), 1) with HTTMock(resp_cont): - result = self.gl.http_list('/projects', all=True) + result = self.gl.http_list("/projects", all=True) self.assertIsInstance(result, list) self.assertEqual(len(result), 1) def test_list_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="get" + ) def resp_cont(url, request): - content = {'Here is why it failed'} + content = {"Here is why it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, self.gl.http_list, '/not_there') + self.assertRaises(GitlabHttpError, self.gl.http_list, "/not_there") def test_list_request_invalid_data(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="get" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '["name": "project1"]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabParsingError, self.gl.http_list, - '/projects') + self.assertRaises(GitlabParsingError, self.gl.http_list, "/projects") def test_post_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="post" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"name": "project1"}' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_post('/projects') + result = self.gl.http_post("/projects") self.assertIsInstance(result, dict) - self.assertEqual(result['name'], 'project1') + self.assertEqual(result["name"], "project1") def test_post_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="post" + ) def resp_cont(url, request): - content = {'Here is wh it failed'} + content = {"Here is wh it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, self.gl.http_post, '/not_there') + self.assertRaises(GitlabHttpError, self.gl.http_post, "/not_there") def test_post_request_invalid_data(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="post" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '["name": "project1"]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabParsingError, self.gl.http_post, - '/projects') + self.assertRaises(GitlabParsingError, self.gl.http_post, "/projects") def test_put_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="put") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="put" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"name": "project1"}' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_put('/projects') + result = self.gl.http_put("/projects") self.assertIsInstance(result, dict) - self.assertEqual(result['name'], 'project1') + self.assertEqual(result["name"], "project1") def test_put_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="put") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="put" + ) def resp_cont(url, request): - content = {'Here is wh it failed'} + content = {"Here is wh it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, self.gl.http_put, '/not_there') + self.assertRaises(GitlabHttpError, self.gl.http_put, "/not_there") def test_put_request_invalid_data(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="put") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="put" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '["name": "project1"]' return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabParsingError, self.gl.http_put, - '/projects') + self.assertRaises(GitlabParsingError, self.gl.http_put, "/projects") def test_delete_request(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects", - method="delete") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects", method="delete" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} - content = 'true' + headers = {"content-type": "application/json"} + content = "true" return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): - result = self.gl.http_delete('/projects') + result = self.gl.http_delete("/projects") self.assertIsInstance(result, requests.Response) self.assertEqual(result.json(), True) def test_delete_request_404(self): - @urlmatch(scheme="http", netloc="localhost", - path="/api/v4/not_there", method="delete") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/not_there", method="delete" + ) def resp_cont(url, request): - content = {'Here is wh it failed'} + content = {"Here is wh it failed"} return response(404, content, {}, None, 5, request) with HTTMock(resp_cont): - self.assertRaises(GitlabHttpError, self.gl.http_delete, - '/not_there') + self.assertRaises(GitlabHttpError, self.gl.http_delete, "/not_there") class TestGitlabAuth(unittest.TestCase): def test_invalid_auth_args(self): - self.assertRaises(ValueError, - Gitlab, - "http://localhost", api_version='4', - private_token='private_token', oauth_token='bearer') - self.assertRaises(ValueError, - Gitlab, - "http://localhost", api_version='4', - oauth_token='bearer', http_username='foo', - http_password='bar') - self.assertRaises(ValueError, - Gitlab, - "http://localhost", api_version='4', - private_token='private_token', http_password='bar') - self.assertRaises(ValueError, - Gitlab, - "http://localhost", api_version='4', - private_token='private_token', http_username='foo') + self.assertRaises( + ValueError, + Gitlab, + "http://localhost", + api_version="4", + private_token="private_token", + oauth_token="bearer", + ) + self.assertRaises( + ValueError, + Gitlab, + "http://localhost", + api_version="4", + oauth_token="bearer", + http_username="foo", + http_password="bar", + ) + self.assertRaises( + ValueError, + Gitlab, + "http://localhost", + api_version="4", + private_token="private_token", + http_password="bar", + ) + self.assertRaises( + ValueError, + Gitlab, + "http://localhost", + api_version="4", + private_token="private_token", + http_username="foo", + ) def test_private_token_auth(self): - gl = Gitlab('http://localhost', private_token='private_token', - api_version='4') - self.assertEqual(gl.private_token, 'private_token') + gl = Gitlab("http://localhost", private_token="private_token", api_version="4") + self.assertEqual(gl.private_token, "private_token") self.assertEqual(gl.oauth_token, None) self.assertEqual(gl._http_auth, None) - self.assertEqual(gl.headers['PRIVATE-TOKEN'], 'private_token') - self.assertNotIn('Authorization', gl.headers) + self.assertEqual(gl.headers["PRIVATE-TOKEN"], "private_token") + self.assertNotIn("Authorization", gl.headers) def test_oauth_token_auth(self): - gl = Gitlab('http://localhost', oauth_token='oauth_token', - api_version='4') + gl = Gitlab("http://localhost", oauth_token="oauth_token", api_version="4") self.assertEqual(gl.private_token, None) - self.assertEqual(gl.oauth_token, 'oauth_token') + self.assertEqual(gl.oauth_token, "oauth_token") self.assertEqual(gl._http_auth, None) - self.assertEqual(gl.headers['Authorization'], 'Bearer oauth_token') - self.assertNotIn('PRIVATE-TOKEN', gl.headers) + self.assertEqual(gl.headers["Authorization"], "Bearer oauth_token") + self.assertNotIn("PRIVATE-TOKEN", gl.headers) def test_http_auth(self): - gl = Gitlab('http://localhost', private_token='private_token', - http_username='foo', http_password='bar', api_version='4') - self.assertEqual(gl.private_token, 'private_token') + gl = Gitlab( + "http://localhost", + private_token="private_token", + http_username="foo", + http_password="bar", + api_version="4", + ) + self.assertEqual(gl.private_token, "private_token") self.assertEqual(gl.oauth_token, None) self.assertIsInstance(gl._http_auth, requests.auth.HTTPBasicAuth) - self.assertEqual(gl.headers['PRIVATE-TOKEN'], 'private_token') - self.assertNotIn('Authorization', gl.headers) + self.assertEqual(gl.headers["PRIVATE-TOKEN"], "private_token") + self.assertNotIn("Authorization", gl.headers) class TestGitlab(unittest.TestCase): - def setUp(self): - self.gl = Gitlab("http://localhost", private_token="private_token", - email="testuser@test.com", password="testpassword", - ssl_verify=True, api_version=4) + self.gl = Gitlab( + "http://localhost", + private_token="private_token", + email="testuser@test.com", + password="testpassword", + ssl_verify=True, + api_version=4, + ) def test_pickability(self): original_gl_objects = self.gl._objects pickled = pickle.dumps(self.gl) unpickled = pickle.loads(pickled) self.assertIsInstance(unpickled, Gitlab) - self.assertTrue(hasattr(unpickled, '_objects')) + self.assertTrue(hasattr(unpickled, "_objects")) self.assertEqual(unpickled._objects, original_gl_objects) def test_credentials_auth_nopassword(self): self.gl.email = None self.gl.password = None - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/session", - method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/session", method="post" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"message": "message"}'.encode("utf-8") return response(404, content, headers, None, 5, request) @@ -417,10 +465,11 @@ class TestGitlab(unittest.TestCase): self.assertRaises(GitlabHttpError, self.gl._credentials_auth) def test_credentials_auth_notok(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/session", - method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/session", method="post" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"message": "message"}'.encode("utf-8") return response(404, content, headers, None, 5, request) @@ -441,12 +490,14 @@ class TestGitlab(unittest.TestCase): id_ = 1 expected = {"PRIVATE-TOKEN": token} - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/session", - method="post") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/session", method="post" + ) def resp_cont(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{{"id": {0:d}, "private_token": "{1:s}"}}'.format( - id_, token).encode("utf-8") + id_, token + ).encode("utf-8") return response(201, content, headers, None, 5, request) with HTTMock(resp_cont): @@ -461,12 +512,12 @@ class TestGitlab(unittest.TestCase): name = "username" id_ = 1 - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/user", - method="get") + @urlmatch(scheme="http", netloc="localhost", path="/api/v4/user", method="get") def resp_cont(url, request): - headers = {'content-type': 'application/json'} - content = '{{"id": {0:d}, "username": "{1:s}"}}'.format( - id_, name).encode("utf-8") + headers = {"content-type": "application/json"} + content = '{{"id": {0:d}, "username": "{1:s}"}}'.format(id_, name).encode( + "utf-8" + ) return response(200, content, headers, None, 5, request) with HTTMock(resp_cont): @@ -476,10 +527,11 @@ class TestGitlab(unittest.TestCase): self.assertEqual(type(self.gl.user), CurrentUser) def test_hooks(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/hooks/1", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/hooks/1", method="get" + ) def resp_get_hook(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"url": "testurl", "id": 1}'.encode("utf-8") return response(200, content, headers, None, 5, request) @@ -490,10 +542,11 @@ class TestGitlab(unittest.TestCase): self.assertEqual(data.id, 1) def test_projects(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/projects/1", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/projects/1", method="get" + ) def resp_get_project(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"name": "name", "id": 1}'.encode("utf-8") return response(200, content, headers, None, 5, request) @@ -504,12 +557,13 @@ class TestGitlab(unittest.TestCase): self.assertEqual(data.id, 1) def test_groups(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/groups/1", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/groups/1", method="get" + ) def resp_get_group(url, request): - headers = {'content-type': 'application/json'} + headers = {"content-type": "application/json"} content = '{"name": "name", "id": 1, "path": "path"}' - content = content.encode('utf-8') + content = content.encode("utf-8") return response(200, content, headers, None, 5, request) with HTTMock(resp_get_group): @@ -520,27 +574,30 @@ class TestGitlab(unittest.TestCase): self.assertEqual(data.id, 1) def test_issues(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/issues", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/issues", method="get" + ) def resp_get_issue(url, request): - headers = {'content-type': 'application/json'} - content = ('[{"name": "name", "id": 1}, ' - '{"name": "other_name", "id": 2}]') + headers = {"content-type": "application/json"} + content = '[{"name": "name", "id": 1}, ' '{"name": "other_name", "id": 2}]' content = content.encode("utf-8") return response(200, content, headers, None, 5, request) with HTTMock(resp_get_issue): data = self.gl.issues.list() self.assertEqual(data[1].id, 2) - self.assertEqual(data[1].name, 'other_name') + self.assertEqual(data[1].name, "other_name") def test_users(self): - @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", - method="get") + @urlmatch( + scheme="http", netloc="localhost", path="/api/v4/users/1", method="get" + ) def resp_get_user(url, request): - headers = {'content-type': 'application/json'} - content = ('{"name": "name", "id": 1, "password": "password", ' - '"username": "username", "email": "email"}') + headers = {"content-type": "application/json"} + content = ( + '{"name": "name", "id": 1, "password": "password", ' + '"username": "username", "email": "email"}' + ) content = content.encode("utf-8") return response(200, content, headers, None, 5, request) @@ -558,13 +615,14 @@ class TestGitlab(unittest.TestCase): def test_from_config(self): config_path = self._default_config() - gitlab.Gitlab.from_config('one', [config_path]) + gitlab.Gitlab.from_config("one", [config_path]) os.unlink(config_path) def test_subclass_from_config(self): class MyGitlab(gitlab.Gitlab): pass + config_path = self._default_config() - gl = MyGitlab.from_config('one', [config_path]) - self.assertEqual(type(gl).__name__, 'MyGitlab') + gl = MyGitlab.from_config("one", [config_path]) + self.assertEqual(type(gl).__name__, "MyGitlab") os.unlink(config_path) |