From c7bcc25a361f9df440f9c972672e5eec3b057625 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Mon, 31 May 2021 10:47:03 -0700 Subject: fix: catch invalid type used to initialize RESTObject Sometimes we have errors where we don't get a dictionary passed to RESTObject.__init__() method. This breaks things but in confusing ways. Check in the __init__() method and raise an exception if it occurs. --- tests/unit/test_base.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/test_base.py b/tests/unit/test_base.py index b3a58fc..8872dbd 100644 --- a/tests/unit/test_base.py +++ b/tests/unit/test_base.py @@ -19,6 +19,7 @@ import pickle import pytest +import gitlab from gitlab import base @@ -85,6 +86,10 @@ class TestRESTObject: 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 -- cgit v1.2.1