Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: catch invalid type used to initialize RESTObject#1487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intopython-gitlab:masterfromJohnVillalovos:jlvillal/check_attrs
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionsgitlab/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@
from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type

from gitlab import types as g_types
from gitlab.exceptions import GitlabParsingError

from .client import Gitlab, GitlabList

Expand DownExpand Up@@ -51,6 +52,12 @@ class RESTObject(object):
manager: "RESTManager"

def __init__(self, manager: "RESTManager", attrs: Dict[str, Any]) -> None:
if not isinstance(attrs, dict):
raise GitlabParsingError(
"Attempted to initialize RESTObject with a non-dictionary value: "
"{!r}\nThis likely indicates an incorrect or malformed server "
"response.".format(attrs)
)
self.__dict__.update(
{
"manager": manager,
Expand Down
5 changes: 5 additions & 0 deletionstests/unit/test_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,7 @@

import pytest

import gitlab
from gitlab import base


Expand DownExpand Up@@ -85,6 +86,10 @@ def test_instantiate(self, fake_gitlab, fake_manager):
assert fake_manager == obj.manager
assert fake_gitlab == obj.manager.gitlab

def test_instantiate_non_dict(self, fake_gitlab, fake_manager):
with pytest.raises(gitlab.exceptions.GitlabParsingError):
FakeObject(fake_manager, ["a", "list", "fails"])

def test_picklability(self, fake_manager):
obj = FakeObject(fake_manager, {"foo": "bar"})
original_obj_module = obj._module
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp