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

Function test_property_sources

tests/test_oinspect.py:303–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

301
302
303def test_property_sources():
304 # A simple adder whose source and signature stays
305 # the same across Python distributions
306 def simple_add(a, b):
307 "Adds two numbers"
308 return a + b
309
310 class A(object):
311 @property
312 def foo(self):
313 return "bar"
314
315 foo = foo.setter(lambda self, v: setattr(self, "bar", v))
316
317 dname = property(oinspect.getdoc)
318 adder = property(simple_add)
319
320 i = inspector.info(A.foo, detail_level=1)
321 assert "def foo(self):" in i["source"]
322 assert "lambda self, v:" in i["source"]
323
324 i = inspector.info(A.dname, detail_level=1)
325 assert "def getdoc(obj)" in i["source"]
326
327 i = inspector.info(A.adder, detail_level=1)
328 assert "def simple_add(a, b)" in i["source"]
329
330
331def test_property_docstring_is_in_info_for_detail_level_0():

Callers

nothing calls this directly

Calls 1

infoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…