-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
change doctest DocTestSuite not to raise ValueError if no docstrings #60120
Comments
Currently, calling doctest.DocTestSuite() raises a ValueError if the module passed to it has no docstrings. This was the subject of bpo-14649. This issue is to discuss and possibly change DocTestSuite's behavior not to raise an exception in that situation. In the discussion for bpo-14649 (in particular with R. David Murray), it was acknowledged that the current behavior probably isn't correct or desirable. However, treating the behavior as a bug and fixing it in maintenance branches would have been too big of a change. Thus, if this change is made, it could be slated for the next feature release. |
I'm attaching a patch that changes DocTestSuite's default behaviour as suggested. |
Hmm. This patch still raises the "has no docstrings" ValueError if "not tests" is True. And because the patch changes the default DocTestFinder, it's possible that the patch changes behavior in non-error use cases. Why not just return an empty TestSuite if not tests is True? IIRC, this was the conclusion of the bpo-14649 discussion. |
I've attached a patch that uses the original default DocTestFinder and does not raise an exception when there are no tests. |
This looks good, however we also need a documentation change indicating the new behavior, including a '.. versionchanged:: 3.5' tag, and an entry in whatsnew/3.5 in the 'other changes' section. |
Added docs to patch |
New changeset 57fb5441a4aa by R David Murray in branch 'default': |
Thanks, Glenn. |
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: