gh-61648: Detect line numbers of properties in doctests (GH-113161)

This commit is contained in:
Serhiy Storchaka 2023-12-15 15:24:30 +02:00 committed by GitHub
parent 737d23ffcd
commit 8f8f0f97e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View file

@ -1136,6 +1136,8 @@ class DocTestFinder:
# Find the line number for functions & methods.
if inspect.ismethod(obj): obj = obj.__func__
if isinstance(obj, property):
obj = obj.fget
if inspect.isfunction(obj) and getattr(obj, '__doc__', None):
# We don't use `docstring` var here, because `obj` can be changed.
obj = obj.__code__