Issue4037
Created on 2008-10-04 00:13 by daaku, last changed 2010-02-11 12:40 by ncoghlan.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
patch
|
stevenjd,
2010-02-07 00:44
|
patch to add support for method descriptors to doctest.DocTestFinder |
|
|
|
doctest_test.py
|
stevenjd,
2010-02-09 13:26
|
|
|
|
|
msg74285 - (view) |
Author: (daaku) |
Date: 2008-10-04 00:13 |
|
doctest.py currently does not include doctests from method descriptors
in a class.
The patch is simple, in the _find function in class DocTestFinder:
Original:
# Recurse to methods, properties, and nested classes.
if ((inspect.isfunction(val) or inspect.isclass(val) or
isinstance(val, property)) and
self._from_module(module, val)):
Patched:
# Recurse to methods, properties, and nested classes.
if ((inspect.isfunction(val) or inspect.isclass(val) or
inspect.ismethoddescriptor(val) or
isinstance(val, property)) and
self._from_module(module, val)):
Adding the "inspect.ismethoddescriptor(val) or" line.
|
|
msg98974 - (view) |
Author: Steven D'Aprano (stevenjd) |
Date: 2010-02-07 00:44 |
|
The patch you suggest is *not* sufficient, at least not by my testing.
However, the attached patch does work, according to my tests.
|
|
msg98983 - (view) |
Author: Terry J. Reedy (tjreedy) |
Date: 2010-02-07 05:53 |
|
I am not sure whether this would be considered a bugfix or a new feature.
(ie, whether it would apply to 2.6 and 3.1 or not)
But the change is needed for 3.x also.
I am not sure whether the doc needs changing. A testcase should be added to doctest-test.
|
|
msg99115 - (view) |
Author: Steven D'Aprano (stevenjd) |
Date: 2010-02-09 13:26 |
|
Attached is a simple test script for the patch I submitted. I have tested it with Python 2.6 both before and after applying the patch. Run it from the command line.
With the unpatched doctest module, it prints:
"Expected 2 doctests, but only found 1"
After the patch, it finds and runs both doctests, and prints nothing.
|
|
msg99145 - (view) |
Author: Brian Curtin (brian.curtin) * |
Date: 2010-02-10 01:31 |
|
Can you add your test(s) in Lib/test/test_doctest.py ? That way it will be run with the Python regression suite. Ideally a documentation update would come with the patch. Also, line length should ideally be capped at 79 characters (re: PEP-8).
Might as well move the valname string building outside of both if-tests since it's common to both of them.
Terry: this looks like a feature rather than a bug, removing 2.6/3.1.
|
|
| Date |
User |
Action |
Args |
| 2010-02-11 12:40:53 | ncoghlan | set | nosy:
+ ncoghlan
|
| 2010-02-10 01:31:47 | brian.curtin | set | nosy:
+ brian.curtin versions:
- Python 2.6, Python 3.1 messages:
+ msg99145 priority: normal keywords:
+ patch, needs review type: feature request stage: patch review |
| 2010-02-09 13:26:49 | stevenjd | set | files:
+ doctest_test.py
messages:
+ msg99115 |
| 2010-02-07 05:53:03 | tjreedy | set | nosy:
+ tjreedy
messages:
+ msg98983 versions:
+ Python 3.1, Python 2.7, Python 3.2 |
| 2010-02-07 00:44:48 | stevenjd | set | files:
+ patch nosy:
+ stevenjd messages:
+ msg98974
|
| 2008-10-04 00:13:25 | daaku | create | |
|