This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: doctest not working on nested functions
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: baptiste.carvello, dabrahams, eric.araujo, flox, georg.brandl, ncoghlan
Priority: normal Keywords: needs review, patch

Created on 2011-05-11 11:56 by dabrahams, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
bug.py dabrahams, 2011-05-11 11:56
issue12055-32.diff baptiste.carvello, 2011-05-23 15:15 adds feature + doc and tests for 3.2
issue12055-27.diff baptiste.carvello, 2011-05-23 16:15
Messages (8)
msg135770 - (view) Author: Dave Abrahams (dabrahams) Date: 2011-05-11 11:56
The attached file demonstrates
msg136653 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-23 14:54
From http://docs.python.org/dev/library/doctest#which-docstrings-are-examined :

“The module docstring, and all function, class and method docstrings are searched. Objects imported into the module are not searched. [...] Any classes found are recursively searched similarly, to test docstrings in their contained methods and nested classes.”

The doc does not advertise support for nested functions, so this would be a new feature, if deemed useful.
msg136661 - (view) Author: Baptiste Carvello (baptiste.carvello) Date: 2011-05-23 15:15
Hello,

the attached patch adds the requested feature to 3.2 (the patch is based on 6d67931c63f9), with appropriate doc changes and tests for the new behaviour.

It does not apply to 2.7, so I'll send another patch for that soon.
msg136664 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-23 15:48
New features don’t go in stable versions.
msg136669 - (view) Author: Baptiste Carvello (baptiste.carvello) Date: 2011-05-23 16:15
here is the patch for 2.7.

Dave: I don't know if or when the patch will be accepted, as this is a new 
feature. In the meantime, you can easily patch your system. As the code changes 
are all in Python, you don't need to recompile. Going to your standard library 
directory and running a command like the following should do the trick:

filterdiff -i '*/doctest.py' issue12055-27.diff | patch
msg136673 - (view) Author: Dave Abrahams (dabrahams) Date: 2011-05-23 16:21
It's certainly much appreciated, but my tests have to run with a stock
python, so I worked around the problem  personally.  I just reported
this because I found (surprisingly, to me) that some of my tests had
been silently not-running, which seems like a bad feature of any
testing system ;=).

On Mon, May 23, 2011 at 12:15 PM, Baptiste Carvello
<report@bugs.python.org> wrote:
>
> Baptiste Carvello <devel@baptiste-carvello.net> added the comment:
>
> here is the patch for 2.7.
>
> Dave: I don't know if or when the patch will be accepted, as this is a new
> feature. In the meantime, you can easily patch your system. As the code changes
> are all in Python, you don't need to recompile. Going to your standard library
> directory and running a command like the following should do the trick:
>
> filterdiff -i '*/doctest.py' issue12055-27.diff | patch
>
> ----------
> Added file: http://bugs.python.org/file22085/issue12055-27.diff
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue12055>
> _______________________________________
msg136687 - (view) Author: Baptiste Carvello (baptiste.carvello) Date: 2011-05-23 18:04
Eric: my bad, I guess I was living in the past, before 3.2 was released :-)

Anyway, my 3.2 patch applies to default (6354b4ceba1d), with just a one-line 
offset for test_doctest.py. All tests pass.

By the way, my 2.7 patch was based on 76e5fe8e21fd.
msg136757 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-24 16:00
2.7 and 3.2 are the present, but we work for the future :)  Thanks for the patch.

I’m adding to the nosy list the developers who committed the most recent changes to doctest so that someone can decide whether this new feature is desirable and review the patch.
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56264
2011-05-24 16:00:11eric.araujosetnosy: + georg.brandl, ncoghlan, flox
messages: + msg136757

keywords: + needs review
stage: needs patch -> patch review
2011-05-23 18:04:36baptiste.carvellosetmessages: + msg136687
2011-05-23 16:21:31dabrahamssetmessages: + msg136673
2011-05-23 16:15:05baptiste.carvellosetfiles: + issue12055-27.diff

messages: + msg136669
2011-05-23 15:48:37eric.araujosettype: enhancement
messages: + msg136664
versions: + Python 3.3, - Python 2.6, Python 2.7
2011-05-23 15:15:40baptiste.carvellosetfiles: + issue12055-32.diff

type: enhancement -> (no value)
versions: + Python 2.6, Python 2.7, - Python 3.3
keywords: + patch
nosy: + baptiste.carvello

messages: + msg136661
2011-05-23 14:54:58eric.araujosetversions: - Python 3.1, Python 2.7, Python 3.2
nosy: + eric.araujo

messages: + msg136653

type: enhancement
2011-05-23 14:53:20eric.araujosetstage: needs patch
versions: + Python 3.1, Python 3.2, Python 3.3, - Python 2.6
2011-05-11 11:56:40dabrahamscreate