| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 161bb0b commit c7bcc25
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ | |||
| 20 | 20 | from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type | |
| 21 | 21 | ||
| 22 | 22 | from gitlab import types as g_types | |
| 23 | + from gitlab.exceptions import GitlabParsingError | ||
| 23 | 24 | ||
| 24 | 25 | from .client import Gitlab, GitlabList | |
| 25 | 26 | ||
@@ -51,6 +52,12 @@ class RESTObject(object): | |||
| 51 | 52 | manager: "RESTManager" | |
| 52 | 53 | ||
| 53 | 54 | def __init__(self, manager: "RESTManager", attrs: Dict[str, Any]) -> None: | |
| 55 | + if not isinstance(attrs, dict): | ||
| 56 | + raise GitlabParsingError( | ||
| 57 | + "Attempted to initialize RESTObject with a non-dictionary value: " | ||
| 58 | + "{!r}\nThis likely indicates an incorrect or malformed server " | ||
| 59 | + "response.".format(attrs) | ||
| 60 | + ) | ||
| 54 | 61 | self.__dict__.update( | |
| 55 | 62 | { | |
| 56 | 63 | "manager": manager, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | import pytest | |
| 21 | 21 | ||
| 22 | + import gitlab | ||
| 22 | 23 | from gitlab import base | |
| 23 | 24 | ||
| 24 | 25 | ||
@@ -85,6 +86,10 @@ def test_instantiate(self, fake_gitlab, fake_manager): | |||
| 85 | 86 | assert fake_manager == obj.manager | |
| 86 | 87 | assert fake_gitlab == obj.manager.gitlab | |
| 87 | 88 | ||
| 89 | + def test_instantiate_non_dict(self, fake_gitlab, fake_manager): | ||
| 90 | + with pytest.raises(gitlab.exceptions.GitlabParsingError): | ||
| 91 | + FakeObject(fake_manager, ["a", "list", "fails"]) | ||
| 92 | + | ||
| 88 | 93 | def test_picklability(self, fake_manager): | |
| 89 | 94 | obj = FakeObject(fake_manager, {"foo": "bar"}) | |
| 90 | 95 | original_obj_module = obj._module | |
| Back | FazBrowse Home | New Git URL |
0 commit comments