[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- nosy: -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Filip Zyzniewski added the comment: It seems like there is also an issue with property classes defined in a different module. In the example below Foo.x uses standard property, and Foo.y uses prop imported from the prop module. This results in docstring for Foo.y to be missed: filip@klocek:~/test$ cat prop.py class prop(property): pass filip@klocek:~/test$ cat foo.py from prop import prop class Foo(object): @property def x(self): Foo().x 'x' return 'x' @prop def y(self): Foo().y 'y' return 'y' filip@klocek:~/test$ python --version Python 2.7.3 filip@klocek:~/test$ python -m doctest foo.py -v Trying: Foo().x Expecting: 'x' ok 2 items had no tests: foo foo.Foo 1 items passed all tests: 1 tests in foo.Foo.x 1 tests in 3 items. 1 passed and 0 failed. Test passed. filip@klocek:~/test$ python3 --version Python 3.2.3 filip@klocek:~/test$ python3 -m doctest foo.py -v Trying: Foo().x Expecting: 'x' ok 2 items had no tests: foo foo.Foo 1 items passed all tests: 1 tests in foo.Foo.x 1 tests in 3 items. 1 passed and 0 failed. Test passed. filip@klocek:~/test$ -- nosy: +filip.zyzniewski ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Mark Lawrence breamore...@yahoo.co.uk added the comment: Could someone please respond to Georg's comment msg104300, thanks. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Georg Brandl ge...@python.org added the comment: So for staticmethods and classmethods, valname doesn't need to be reassigned? -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Steven D'Aprano steve+pyt...@pearwood.info added the comment: I have fixed the issue with line length, and taken Brian's advice re valname. Updated patch for doctest and test.test_doctest2 is attached. -- Added file: http://bugs.python.org/file16599/doctest_patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Changes by Nick Coghlan ncogh...@gmail.com: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Steven D'Aprano steve+pyt...@pearwood.info added the comment: 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. -- Added file: http://bugs.python.org/file16185/doctest_test.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Brian Curtin cur...@acm.org added the comment: 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. -- keywords: +needs review, patch nosy: +brian.curtin priority: - normal stage: - patch review type: - feature request versions: -Python 2.6, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Steven D'Aprano steve+pyt...@pearwood.info added the comment: The patch you suggest is *not* sufficient, at least not by my testing. However, the attached patch does work, according to my tests. -- nosy: +stevenjd Added file: http://bugs.python.org/file16158/patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
Terry J. Reedy tjre...@udel.edu added the comment: 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. -- nosy: +tjreedy versions: +Python 2.7, Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4037] doctest.py should include method descriptors when looking inside a class __dict__
New submission from daaku [EMAIL PROTECTED]: 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. -- components: Library (Lib) messages: 74285 nosy: daaku severity: normal status: open title: doctest.py should include method descriptors when looking inside a class __dict__ versions: Python 2.6 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4037 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com