-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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 fails to find doctests in extension modules #47408
Comments
Doctest fails to find doctests defined in extension modules. With tools --- doctest_ori.py 2008-06-20 19:22:56.000000000 -0700
+++ doctest.py 2008-06-20 19:23:53.000000000 -0700
@@ -887,7 +887,8 @@
for valname, val in obj.__dict__.items():
valname = '%s.%s' % (name, valname)
# Recurse to functions & classes.
- if ((inspect.isfunction(val) or inspect.isclass(val)) and
+ if ((inspect.isfunction(val) or inspect.isclass(val) or
+ inspect.isbuiltin(val) ) and
self._from_module(module, val)):
self._find(tests, val, valname, module, source_lines,
globs, seen) However, it is likely not sufficient as it doesn't take into account the For purposes of doctesting, doctest should simply care:
But in too many places in doctest there are currently assumptions about BTW, in that process doctest will hopefully be made more modular and |
For me, a 'function' is written in Python, a 'builtin' is written in C. The fact that it is defined in an extension module is irrelevant, and maybe inspect.isroutine() is the correct test here. |
I think there are two issues that need to be separated:
The language exposes its builtins via the __builtin__ module precisely http://docs.python.org/lib/built-in-funcs.html a section that starts: """2.1 Built-in Functions The Python interpreter has a number of functions built into it that are Nowhere does it say that "builtins are written in C and functions in In summary, I'm happy with any fix for the bug, but I very strongly And by the way, by 'extension module' I mean to describe C-extensions, |
I've added Tim Peters to the nosy list. Is there anyone else who should There are some details (and a workaround) in Cython FAQ: |
In looking at test_decimal for bpo-16748, I discovered that not all of the doctests for _decimal are being tested. So, I fixed it (or at least tried to :). This patch does the following:
|
Ping! Anyone able to do a review of this patch? It still applies cleanly to default (or even 3.3, if this qualifies as a bug rather than a new feature). |
Added some review comments. Because it could cause possibly buggy doctest fragments to run that previously did not run, I don't think it should be backported as a bug fix. |
Here's a new version of the patch that I think addresses the points in your review (which I've also replied to on Rietveld). And I agree about not backporting. |
Does this qualify as a new feature that needs to be in before beta 1? |
Larry: thoughts? |
In the absence of input, I'm going to go ahead and commit this just in case in needs to be in before feature freeze, but I'll leave the issue open at "commit review" stage for a few days in case anyone does have something to say about it. |
New changeset 95dc3054959b by Zachary Ware in branch 'default': |
One-year-olds don't like productivity. Committed, 3 hours after I said I would :). I'll leave this open for a couple days just in case. |
New changeset 30b95368d253 by Zachary Ware in branch 'default': |
I think there's an issue with this change - ismethoddescriptor() doesn't guarantee that that the object has an __objclass__ attribute. Unbound PyQt4 signals appear to be a case where this goes wrong. This came up testing IPython on Python 3.4 - we subclass DocTestFinder, which creates other problems, but it looks like it would run into trouble even with the base implementation. |
Does this patch fix things for you? |
the patch seems to work for me in ipython. |
New changeset c964b6b83720 by Zachary Ware in branch 'default': |
Done. |
New changeset 8520e0ff8e36 by R David Murray in branch 'default': |
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: