Skip to content

a doctest debug runner can keep directives after a failed example #163094

Backlog

Description

@tonghuaroot

Bug report

an ellipsis directive on a failed example stays enabled when the same debug runner starts the next test. this lets an incorrect example pass.

import doctest

runner = doctest.DebugRunner(verbose=False)
parser = doctest.DocTestParser()
for source in (">>> print('actual')  # doctest: +ELLIPSIS\nwrong",
               ">>> print('actual')\na..."):
    test = parser.get_doctest(source, {}, "example", None, 0)
    try:
        runner.run(test)
    except doctest.DocTestFailure:
        continue
    raise AssertionError("the example unexpectedly passed")

CPython versions tested on:

3.11, 3.12, 3.13, 3.14, 3.15, CPython main branch

Operating systems tested on:

Linux, macOS

Linked PRs

Activity

  1. added
    stdlib
    type-bug
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions