MCPcopy Index your code
hub / github.com/ipython/ipython / test_info

Function test_info

tests/test_oinspect.py:190–224  ·  view source on GitHub ↗

Check that Inspector.info fills out various fields as expected.

()

Source from the content-addressed store, hash-verified

188
189
190def test_info():
191 "Check that Inspector.info fills out various fields as expected."
192 i = inspector.info(Call, oname="Call")
193 assert i["type_name"] == "type"
194 expected_class = str(type(type)) # <class 'type'> (Python 3) or <type 'type'>
195 assert i["base_class"] == expected_class
196 assert re.search(
197 "<class 'tests.test_oinspect.Call'( at 0x[0-9a-f]{1,9})?>",
198 i["string_form"],
199 )
200 fname = __file__
201 if fname.endswith(".pyc"):
202 fname = fname[:-1]
203 # case-insensitive comparison needed on some filesystems
204 # e.g. Windows:
205 assert i["file"].lower() == compress_user(fname).lower()
206 assert i["definition"] == None
207 assert i["docstring"] == Call.__doc__
208 assert i["source"] == None
209 assert i["isclass"] is True
210 assert i["init_definition"] == "Call(x, y=1)"
211 assert i["init_docstring"] == Call.__init__.__doc__
212
213 i = inspector.info(Call, detail_level=1)
214 assert i["source"] is not None
215 assert i["docstring"] == None
216
217 c = Call(1)
218 c.__doc__ = "Modified instance docstring"
219 i = inspector.info(c)
220 assert i["type_name"] == "Call"
221 assert i["docstring"] == "Modified instance docstring"
222 assert i["class_docstring"] == Call.__doc__
223 assert i["init_docstring"] == Call.__init__.__doc__
224 assert i["call_docstring"] == Call.__call__.__doc__
225
226
227def test_class_signature():

Callers

nothing calls this directly

Calls 4

compress_userFunction · 0.90
CallClass · 0.85
infoMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…