Skip to content
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

Closed
cjerdonek opened this issue Sep 10, 2012 · 8 comments
Closed

change doctest DocTestSuite not to raise ValueError if no docstrings #60120

cjerdonek opened this issue Sep 10, 2012 · 8 comments
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@cjerdonek
Copy link
Member

BPO 15916
Nosy @ezio-melotti, @bitdancer, @asvetlov, @cjerdonek, @akheron
Files
  • issue15916.patch
  • issue15916-no-exception.patch
  • issue15916-with-docs.patch
  • 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:

    assignee = None
    closed_at = <Date 2014-04-15.00:29:46.123>
    created_at = <Date 2012-09-10.23:54:54.491>
    labels = ['easy', 'type-bug', 'library']
    title = 'change doctest DocTestSuite not to raise ValueError if no docstrings'
    updated_at = <Date 2014-04-15.00:29:46.110>
    user = 'https://github.com/cjerdonek'

    bugs.python.org fields:

    activity = <Date 2014-04-15.00:29:46.110>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-04-15.00:29:46.123>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2012-09-10.23:54:54.491>
    creator = 'chris.jerdonek'
    dependencies = []
    files = ['27673', '34829', '34848']
    hgrepos = []
    issue_num = 15916
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['170250', '173597', '173632', '216145', '216169', '216211', '216255', '216256']
    nosy_count = 8.0
    nosy_names = ['ezio.melotti', 'r.david.murray', 'asvetlov', 'chris.jerdonek', 'python-dev', 'petri.lehtinen', 'tuukka', 'Glenn.Jones']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15916'
    versions = ['Python 3.4']

    @cjerdonek
    Copy link
    Member Author

    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.

    @cjerdonek cjerdonek added stdlib Python modules in the Lib dir easy type-bug An unexpected behavior, bug, or error labels Sep 10, 2012
    @tuukka
    Copy link
    Mannequin

    tuukka mannequin commented Oct 23, 2012

    I'm attaching a patch that changes DocTestSuite's default behaviour as suggested.

    @cjerdonek
    Copy link
    Member Author

    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.

    @GlennJones
    Copy link
    Mannequin

    GlennJones mannequin commented Apr 14, 2014

    I've attached a patch that uses the original default DocTestFinder and does not raise an exception when there are no tests.

    @bitdancer
    Copy link
    Member

    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.

    @GlennJones
    Copy link
    Mannequin

    GlennJones mannequin commented Apr 14, 2014

    Added docs to patch

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 15, 2014

    New changeset 57fb5441a4aa by R David Murray in branch 'default':
    bpo-15916: if there are no docstrings, make empty suite, not an error.
    http://hg.python.org/cpython/rev/57fb5441a4aa

    @bitdancer
    Copy link
    Member

    Thanks, Glenn.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants