You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, as it turns out, the standard library doctest module only inspects methods defined in the class, and skips those from parent classes.
For vanilla doctest, it's fine, because it looks everywhere, including a private superclass.
For strategy="api", it's a problem however.
Possible solutions:
check if there's a hook in DoctestFinder we can use
In DTFinder.find, walk the MRO of an object (in the toy example above, >>> package.B.__mro__ is (<class 'package.B'>, <class 'package._A'>, <class 'object'>)
The text was updated successfully, but these errors were encountered:
From the the doctest sources: DoctestFinder.find only looks at a class __dict__ attribute, and inherited methods are not there:
(Pdb) p obj
<class 'package.B'>
(Pdb) p obj.__dict__.items()
dict_items([('__module__', 'package'), ('__doc__', 'A public subclass.'), ('other_meth', <function B.other_meth at 0x7fc45d499a80>)])
Discovered in scipy/scipy#22027 (comment)
Consider a public class,
B
, which inherits from a private superclass_A
:Instances of
B
have methods from both classes, and one would expect that doctesting finds docstrings of bothB.meth
andB.other_meth
.However, it is not the case with
strategy="api"
!With the default
strategy=None
, both doctests are discovered:So, as it turns out, the standard library
doctest
module only inspects methods defined in the class, and skips those from parent classes.For vanilla
doctest
, it's fine, because it looks everywhere, including a private superclass.For strategy="api", it's a problem however.
Possible solutions:
DoctestFinder
we can useDTFinder.find
, walk the MRO of an object (in the toy example above,>>> package.B.__mro__
is(<class 'package.B'>, <class 'package._A'>, <class 'object'>)
The text was updated successfully, but these errors were encountered: