New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doctest doesn't find nested functions #44538
Comments
If a nested function has doctests, they won't be run:
{{{
def f():
'''
>>> 'a'
'a'
''' def g():
'''
>>> 'a'
'b'
'''
pass pass DocTestFinder will only find f's doctest and won't recurse to find g's, surprising the programmer when they (hopefully) discover that their inner doctest is incorrect! |
DocTestFinder uses object inspection to find docstrings, which doesn't really allow this kind of thing: g isn't created until f is actually run. Making this possible would probably require implementing an alternate doctest finder based on source code inspection (via the new _ast module?). |
Here is a patch that implements this new functionality. |
I believe that there could be interest in this, has anyone taken over doctest from tim_one? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: