]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-44538: Mention nested classes/functions in doctest docs (GH-137870)
authorBartosz Sławecki <bartosz@ilikepython.com>
Mon, 18 Aug 2025 14:58:23 +0000 (16:58 +0200)
committerGitHub <noreply@github.com>
Mon, 18 Aug 2025 14:58:23 +0000 (10:58 -0400)
Doc/library/doctest.rst

index 5a2c6bdd27c386a469fa82b10925dfc6a03b16ee..02b73ccd3f3d1901909659f5b03891048d57d380 100644 (file)
@@ -350,6 +350,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: