GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improved error reporting for doctests run with unittest · Issue #134857 · python/cpython

Improved error reporting for doctests run with unittest #134857

New issue
Copy link
New issue
Copy link
Closed
Closed
Improved error reporting for doctests run with unittest#134857
Copy link
Assignees
serhiy-storchaka
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes

Description

@serhiy-storchaka
serhiy-storchaka
opened on May 28, 2025
Issue body actions

There are several issues with error reports when doctests are wrapped in DocTestCase.

  • When error happens during compilation or execution an example, the traceback contains several lines from doctest.py:

        File ...
          exec(compile(example.source, filename, "single",
          ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                       compileflags, True), test.globs)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
  • When the output differs, the traceback of AssertionError contains other line from doctest.py:

      Traceback (most recent call last):
        File ...
          raise self.failureException(self.format_failure(new.getvalue()))
    
  • Also, the AssertionError message contains redundant newline character.

Linked PRs

  • gh-134857: Improve error report for doctests run with unittest #134858
  • [3.14] gh-134857: Improve error report for doctests run with unittest (GH-134858) #134903

Activity

  1. serhiy-storchaka
    self-assigned this
    on May 28, 2025
  2. serhiy-storchaka
    added this to Unittest & doctest issueson May 28, 2025
  3. github-project-automation
    moved this to Todo in Unittest & doctest issueson May 28, 2025
  4. serhiy-storchaka
    added 2 commits that reference this issue on May 28, 2025

    pythongh-134857: Improve error report for doctests run with unittest

    8b05bc6

    pythongh-134857: Improve error report for doctests run with unittest

    0d32417
  5. serhiy-storchaka commented on May 28, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on May 28, 2025
    MemberAuthor
    More actions

    @hugovk, this is borderline between a bug fix and a new feature. On one hand, the current behavior is wrong. On other hand, it was so from beginning, so some code can depend on exact output, although this is unlikely, because these details look wrong and unstable. So I think that this change can be backported to 3.14, but not to 3.13.

    Reacted by Mickaël Schoentgen
  6. serhiy-storchaka
    added
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on May 28, 2025
  7. serhiy-storchaka
    added a parent issue on May 28, 2025
    • Better integration of doctest with unittest and libregrtest #108885
  8. serhiy-storchaka
    added a commit that references this issue on May 29, 2025

    gh-134857: Improve error report for doctests run with unittest (GH-13…

    cb8a72b
  9. miss-islington
    added a commit that references this issue on May 29, 2025

    pythongh-134857: Improve error report for doctests run with unittest (p…

    7ac3dc3
  10. serhiy-storchaka
    added a commit that references this issue on May 30, 2025

    [3.14] gh-134857: Improve error report for doctests run with unittest (…

    d7d3e69
  11. serhiy-storchaka
    closed this as completedon May 30, 2025
  12. github-project-automation
    moved this from Todo to Done in Unittest & doctest issueson May 30, 2025
  13. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    pythongh-134857: Improve error report for doctests run with unittest (p…

    8d189d6
  14. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-134857: Improve error report for doctests run with unittest (p…

    cb8500a
  15. gostak-dd
    added a commit that references this issue on Jun 2, 2026

    pythongh-134857: Improve error report for doctests run with unittest (p…

    49d3ddc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes

Projects

  • Unittest & doctest issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.