]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 18 Aug 2025 15:05:12 +0000 (17:05 +0200)
committerGitHub <noreply@github.com>
Mon, 18 Aug 2025 15:05:12 +0000 (15:05 +0000)
gh-44538: Mention nested classes/functions in doctest docs (GH-137870)
(cherry picked from commit 138ed6db9f89171983dc32af4e7ad2e73d46a940)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Doc/library/doctest.rst

index d1ccfc20981523592bbb099e691f9aecaf56beab..e6f89ea981acd8ee970b482df42d3706acef96b1 100644 (file)
@@ -346,6 +346,13 @@ searches them recursively for docstrings, which are then scanned for tests.
 Any classes found are recursively searched similarly, to test docstrings in
 their contained methods and nested classes.
 
+.. note::
+
+   ``doctest`` can only automatically discover classes and functions that are
+   defined at the module level or inside other classes.
+
+   Since nested classes and functions only exist when an outer function
+   is called, they cannot be discovered. Define them outside to make them visible.
 
 .. _doctest-finding-examples: