MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / test_object_resolver_error

Function test_object_resolver_error

tests_python/test_resolvers.py:61–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59
60
61def test_object_resolver_error():
62 from _pydevd_bundle.pydevd_resolver import DefaultResolver
63
64 default_resolver = DefaultResolver()
65
66 class MyObject(object):
67 def __init__(self):
68 self.a = 10
69
70 def __dir__(self):
71 return ["a", "b"]
72
73 def __getattribute__(self, attr_name):
74 if attr_name == "b":
75 raise RuntimeError("unavailable")
76 return object.__getattribute__(self, attr_name)
77
78 obj = MyObject()
79 dictionary = default_resolver.get_dictionary(obj)
80 b_value = dictionary.pop("b")
81 assert dictionary == {"a": 10}
82 assert 'raise RuntimeError("unavailable")' in b_value
83
84 contents_debug_adapter_protocol = default_resolver.get_contents_debug_adapter_protocol(obj)
85 b_value = contents_debug_adapter_protocol.pop(-1)
86 assert contents_debug_adapter_protocol == [("a", 10, ".a")]
87 assert b_value[0] == "b"
88 assert 'raise RuntimeError("unavailable")' in b_value[1]
89 assert b_value[2] == ".b"
90
91
92def test_object_resolver_hasattr_error():

Callers

nothing calls this directly

Calls 5

get_dictionaryMethod · 0.95
DefaultResolverClass · 0.90
MyObjectClass · 0.85
popMethod · 0.80

Tested by

no test coverage detected