MCPcopy Create free account
hub / github.com/ipython/ipython / test_property_sources

Function test_property_sources

IPython/core/tests/test_oinspect.py:266–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

264
265
266def test_property_sources():
267 import posixpath
268 # A simple adder whose source and signature stays
269 # the same across Python distributions
270 def simple_add(a, b):
271 "Adds two numbers"
272 return a + b
273
274 class A(object):
275 @property
276 def foo(self):
277 return 'bar'
278
279 foo = foo.setter(lambda self, v: setattr(self, 'bar', v))
280
281 dname = property(posixpath.dirname)
282 adder = property(simple_add)
283
284 i = inspector.info(A.foo, detail_level=1)
285 nt.assert_in('def foo(self):', i['source'])
286 nt.assert_in('lambda self, v:', i['source'])
287
288 i = inspector.info(A.dname, detail_level=1)
289 nt.assert_in('def dirname(p)', i['source'])
290
291 i = inspector.info(A.adder, detail_level=1)
292 nt.assert_in('def simple_add(a, b)', i['source'])
293
294
295def 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