]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-69113: Fix doctest to report line numbers for __test__ strings (#141624)
authorSanyam Khurana <8039608+CuriousLearner@users.noreply.github.com>
Sat, 6 Dec 2025 20:47:08 +0000 (15:47 -0500)
committerGitHub <noreply@github.com>
Sat, 6 Dec 2025 20:47:08 +0000 (15:47 -0500)
commit100e316e53abfff45f2a94987ee7a8622fcd3589
treea43322ba8f958077e7d00aecce4c581f4db9c693
parentc91c373ef6ceab78936d866572023feb642acc73
gh-69113: Fix doctest to report line numbers for __test__ strings (#141624)

Enhanced the _find_lineno method in doctest to correctly identify and
report line numbers for doctests defined in __test__ dictionaries when
formatted as triple-quoted strings.

Finds a non-blank line in the test string and matches it in the source
file, verifying subsequent lines also match to handle duplicate lines.

Previously, doctest would report "line None" for __test__ dictionary
strings, making it difficult to debug failing tests.

Co-authored-by: Jurjen N.E. Bos <jneb@users.sourceforge.net>
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
Lib/doctest.py
Lib/test/test_doctest/test_doctest.py
Misc/NEWS.d/next/Library/2025-11-16-04-40-06.gh-issue-69113.Xy7Fmn.rst [new file with mode: 0644]